Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
WebsiteTest Class Reference
Inheritance diagram for WebsiteTest:

Public Member Functions

 testLoadById ()
 
 testLoadByCode ()
 
 testSetGroupsAndStores ()
 
 testGetGroups ()
 
 testGetGroupIds ()
 
 testGetGroupsCount ()
 
 testGetDefaultGroup ()
 
 testGetStores ()
 
 testGetStoreIds ()
 
 testGetStoreCodes ()
 
 testGetStoresCount ()
 
 testIsCanDelete ()
 
 testGetWebsiteGroupStore ()
 
 testGetDefaultGroupId ()
 
 testGetBaseCurrency ()
 
 testGetDefaultStore ()
 
 testGetDefaultStoresSelect ()
 
 testIsReadonly ()
 
 testCRUD ()
 
 testCollection ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $_model
 

Detailed Description

Definition at line 8 of file WebsiteTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 15 of file WebsiteTest.php.

16  {
18  \Magento\Store\Model\Website::class
19  );
20  $this->_model->load(1);
21  }

◆ testCollection()

testCollection ( )

Definition at line 184 of file WebsiteTest.php.

185  {
186  $collection = $this->_model->getCollection()->joinGroupAndStore()->addIdFilter(1);
187  $this->assertEquals(1, count($collection->getItems()));
188  }

◆ testCRUD()

testCRUD ( )

@magentoAppIsolation enabled @magentoAppArea adminhtml

Definition at line 175 of file WebsiteTest.php.

176  {
177  $this->_model->setData(['code' => 'test_website', 'name' => 'test website', 'default_group_id' => 1]);
178 
179  /* emulate admin store */
180  $crud = new \Magento\TestFramework\Entity($this->_model, ['name' => 'new name']);
181  $crud->testCrud();
182  }

◆ testGetBaseCurrency()

testGetBaseCurrency ( )

Definition at line 145 of file WebsiteTest.php.

146  {
147  $currency = $this->_model->getBaseCurrency();
148  $this->assertInstanceOf(\Magento\Directory\Model\Currency::class, $currency);
149  $this->assertEquals('USD', $currency->getCode());
150  }

◆ testGetDefaultGroup()

testGetDefaultGroup ( )

Definition at line 92 of file WebsiteTest.php.

93  {
94  $defaultGroup = $this->_model->getDefaultGroup();
95  $this->assertInstanceOf(\Magento\Store\Model\Group::class, $defaultGroup);
96  $this->assertEquals(1, $defaultGroup->getId());
97 
98  $this->_model->setDefaultGroupId(null);
99  $this->assertFalse($this->_model->getDefaultGroup());
100  }

◆ testGetDefaultGroupId()

testGetDefaultGroupId ( )

Definition at line 140 of file WebsiteTest.php.

141  {
142  $this->assertEquals(1, $this->_model->getDefaultGroupId());
143  }

◆ testGetDefaultStore()

testGetDefaultStore ( )

Definition at line 152 of file WebsiteTest.php.

153  {
154  $defaultStore = $this->_model->getDefaultStore();
155  $this->assertInstanceOf(\Magento\Store\Model\Store::class, $defaultStore);
156  $this->assertEquals(1, $defaultStore->getId());
157  }

◆ testGetDefaultStoresSelect()

testGetDefaultStoresSelect ( )

Definition at line 159 of file WebsiteTest.php.

160  {
161  $this->assertInstanceOf(\Magento\Framework\DB\Select::class, $this->_model->getDefaultStoresSelect());
162  }

◆ testGetGroupIds()

testGetGroupIds ( )

Definition at line 82 of file WebsiteTest.php.

83  {
84  $this->assertEquals([1 => 1], $this->_model->getGroupIds());
85  }

◆ testGetGroups()

testGetGroups ( )

Definition at line 74 of file WebsiteTest.php.

75  {
76  $groups = $this->_model->getGroups();
77  $this->assertEquals([1], array_keys($groups));
78  $this->assertInstanceOf(\Magento\Store\Model\Group::class, $groups[1]);
79  $this->assertEquals(1, $groups[1]->getId());
80  }

◆ testGetGroupsCount()

testGetGroupsCount ( )

Definition at line 87 of file WebsiteTest.php.

88  {
89  $this->assertEquals(1, $this->_model->getGroupsCount());
90  }

◆ testGetStoreCodes()

testGetStoreCodes ( )

Definition at line 115 of file WebsiteTest.php.

116  {
117  $this->assertEquals([1 => 'default'], $this->_model->getStoreCodes());
118  }

◆ testGetStoreIds()

testGetStoreIds ( )

Definition at line 110 of file WebsiteTest.php.

111  {
112  $this->assertEquals([1 => 1], $this->_model->getStoreIds());
113  }

◆ testGetStores()

testGetStores ( )

Definition at line 102 of file WebsiteTest.php.

103  {
104  $stores = $this->_model->getStores();
105  $this->assertEquals([1], array_keys($stores));
106  $this->assertInstanceOf(\Magento\Store\Model\Store::class, $stores[1]);
107  $this->assertEquals(1, $stores[1]->getId());
108  }

◆ testGetStoresCount()

testGetStoresCount ( )

Definition at line 120 of file WebsiteTest.php.

121  {
122  $this->assertEquals(1, $this->_model->getStoresCount());
123  }

◆ testGetWebsiteGroupStore()

testGetWebsiteGroupStore ( )

Definition at line 132 of file WebsiteTest.php.

133  {
134  $this->assertEquals('1--', $this->_model->getWebsiteGroupStore());
135  $this->_model->setGroupId(123);
136  $this->_model->setStoreId(456);
137  $this->assertEquals('1-123-456', $this->_model->getWebsiteGroupStore());
138  }

◆ testIsCanDelete()

testIsCanDelete ( )

Definition at line 125 of file WebsiteTest.php.

126  {
127  $this->assertFalse($this->_model->isCanDelete());
128  $this->_model->isReadOnly(true);
129  $this->assertFalse($this->_model->isCanDelete());
130  }

◆ testIsReadonly()

testIsReadonly ( )

Definition at line 164 of file WebsiteTest.php.

165  {
166  $this->assertFalse($this->_model->isReadOnly());
167  $this->_model->isReadOnly(true);
168  $this->assertTrue($this->_model->isReadOnly());
169  }

◆ testLoadByCode()

testLoadByCode ( )

@magentoDbIsolation enabled

Definition at line 36 of file WebsiteTest.php.

37  {
38  $this->_model->load('admin');
39  $this->assertEquals(0, $this->_model->getId());
40  $this->assertEquals('admin', $this->_model->getCode());
41  $this->assertEquals('Admin', $this->_model->getName());
42  }

◆ testLoadById()

testLoadById ( )

@magentoDbIsolation enabled

Definition at line 26 of file WebsiteTest.php.

27  {
28  $this->assertEquals(1, $this->_model->getId());
29  $this->assertEquals('base', $this->_model->getCode());
30  $this->assertEquals('Main Website', $this->_model->getName());
31  }

◆ testSetGroupsAndStores()

testSetGroupsAndStores ( )

@covers \Magento\Store\Model\Website::setGroups @covers \Magento\Store\Model\Website::setStores @covers \Magento\Store\Model\Website::getStores

Definition at line 49 of file WebsiteTest.php.

50  {
51  /* Groups */
53  \Magento\Store\Model\Group::class
54  );
55  $expectedGroup->setId(123);
56  $this->_model->setDefaultGroupId($expectedGroup->getId());
57  $this->_model->setGroups([$expectedGroup]);
58 
59  $groups = $this->_model->getGroups();
60  $this->assertSame($expectedGroup, reset($groups));
61 
62  /* Stores */
64  \Magento\Store\Model\Store::class
65  );
66  $expectedStore->setId(456);
67  $expectedGroup->setDefaultStoreId($expectedStore->getId());
68  $this->_model->setStores([$expectedStore]);
69 
70  $stores = $this->_model->getStores();
71  $this->assertSame($expectedStore, reset($stores));
72  }

Field Documentation

◆ $_model

$_model
protected

Definition at line 13 of file WebsiteTest.php.


The documentation for this class was generated from the following file: