public function testGetStoreEmptyParameter() { $storeId = 1; $storeMock = $this->getMockBuilder('Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->setMethods([])->getMock(); $this->storeResolverMock->expects($this->any())->method('getCurrentStoreId')->willReturn($storeId); $this->storeRepositoryMock->expects($this->atLeastOnce())->method('getById')->with($storeId)->willReturn($storeMock); $this->assertInstanceOf('Magento\\Store\\Api\\Data\\StoreInterface', $this->model->getStore()); $this->assertEquals($storeMock, $this->model->getStore()); }
/** * {@inheritdoc} */ public function getStore($storeId = null) { if (!isset($storeId) || '' === $storeId || $storeId === true) { if (!$this->currentStoreId) { \Magento\Framework\Profiler::start('store.resolve'); $this->currentStoreId = $this->storeResolver->getCurrentStoreId(); \Magento\Framework\Profiler::stop('store.resolve'); } $storeId = $this->currentStoreId; } if ($storeId instanceof \Magento\Store\Api\Data\StoreInterface) { return $storeId; } $store = is_numeric($storeId) ? $this->storeRepository->getById($storeId) : $this->storeRepository->get($storeId); return $store; }