|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
6 | 6 |
|
| 7 | +use Magento\Store\Model\ResourceModel\Store as StoreResource; |
| 8 | +use Magento\Store\Model\StoreFactory; |
| 9 | +use Magento\Store\Model\StoreManagerInterface; |
7 | 10 | use Magento\TestFramework\Helper\Bootstrap;
|
8 | 11 |
|
9 |
| -/** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ |
10 |
| -$storeManager = Bootstrap::getObjectManager()->get(\Magento\Store\Model\StoreManagerInterface::class); |
11 |
| - |
12 |
| -/** @var \Magento\Store\Model\Store $store */ |
13 |
| -$store = Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); |
| 12 | +$objectManager = Bootstrap::getObjectManager(); |
| 13 | +/** @var StoreManagerInterface $storeManager */ |
| 14 | +$storeManager = $objectManager->get(StoreManagerInterface::class); |
| 15 | +/** @var StoreFactory $storeFactory */ |
| 16 | +$storeFactory = $objectManager->get(StoreFactory::class); |
| 17 | +/** @var StoreResource $storeResource */ |
| 18 | +$storeResource = $objectManager->get(StoreResource::class); |
14 | 19 | $storeCode = 'fixturestore';
|
15 | 20 |
|
16 |
| -if (!$store->load($storeCode)->getId()) { |
17 |
| - $store->setCode($storeCode) |
18 |
| - ->setWebsiteId($storeManager->getWebsite()->getId()) |
19 |
| - ->setGroupId($storeManager->getWebsite()->getDefaultGroupId()) |
20 |
| - ->setName('Fixture Store') |
21 |
| - ->setSortOrder(10) |
22 |
| - ->setIsActive(1); |
23 |
| - $store->save(); |
24 |
| -} |
| 21 | +$store = $storeFactory->create(); |
| 22 | +$store->setCode($storeCode) |
| 23 | + ->setWebsiteId($storeManager->getWebsite()->getId()) |
| 24 | + ->setGroupId($storeManager->getWebsite()->getDefaultGroupId()) |
| 25 | + ->setName('Fixture Store') |
| 26 | + ->setSortOrder(10) |
| 27 | + ->setIsActive(1); |
| 28 | +$storeResource->save($store); |
25 | 29 |
|
| 30 | +$storeManager->reinitStores(); |
26 | 31 | //if test using this fixture relies on full text functionality it is required to explicitly perform re-indexation
|
0 commit comments