Exemple #1
0
 protected function prepareMockForReinit()
 {
     $websiteId = 1;
     $websiteCode = 'website_code';
     $groupId = 1;
     $storeId = 1;
     $storeCode = 'store_code';
     $websiteCollection = $this->getMock('\\Magento\\Store\\Model\\Resource\\Website\\Collection', [], [], '', false, false);
     $websiteCollection->expects($this->any())->method('setLoadDefault')->with(true);
     $this->mockIterator($websiteCollection, [$this->_websiteMock]);
     $this->_websiteFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_websiteMock));
     $this->_websiteMock->expects($this->any())->method('getCollection')->will($this->returnValue($websiteCollection));
     $groupCollection = $this->getMock('\\Magento\\Store\\Model\\Resource\\Group\\Collection', [], [], '', false, false);
     $groupCollection->expects($this->any())->method('setLoadDefault')->with(true);
     $this->mockIterator($groupCollection, [$this->_groupMock]);
     $this->_groupFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_groupMock));
     $this->_groupMock->expects($this->any())->method('getCollection')->will($this->returnValue($groupCollection));
     $storeCollection = $this->getMock('\\Magento\\Store\\Model\\Resource\\Store\\Collection', [], [], '', false, false);
     $storeCollection->expects($this->any())->method('setLoadDefault')->with(true);
     $this->mockIterator($storeCollection, [$this->_storeMock]);
     $storeCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$this->_storeMock])));
     $storeCollection->expects($this->any())->method('getLastItem')->will($this->returnValue($this->_storeMock));
     $this->_storeFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_storeMock));
     $this->_storeMock->expects($this->any())->method('getCollection')->will($this->returnValue($storeCollection));
     $this->_websiteCollectionFactoryMock->expects($this->any())->method('create')->will($this->returnValue($websiteCollection));
     $this->_groupCollectionFactoryMock->expects($this->any())->method('create')->will($this->returnValue($groupCollection));
     $this->_storeCollectionFactoryMock->expects($this->any())->method('create')->will($this->returnValue($storeCollection));
     $this->_storeMock->expects($this->any())->method('getWebsiteId')->will($this->returnValue($websiteId));
     $this->_storeMock->expects($this->any())->method('getGroupId')->will($this->returnValue($groupId));
     $this->_storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId));
     $this->_storeMock->expects($this->any())->method('getCode')->will($this->returnValue($storeCode));
     $websiteCollection->expects($this->any())->method('getItemById')->will($this->returnValue($this->_websiteMock));
     $groupCollection->expects($this->any())->method('getItemById')->will($this->returnValue($this->_groupMock));
     $this->_groupMock->expects($this->any())->method('getWebsiteId')->will($this->returnValue($websiteId));
     $this->_groupMock->expects($this->any())->method('getId')->will($this->returnValue($groupId));
     $this->_websiteMock->expects($this->any())->method('getId')->will($this->returnValue($websiteId));
     $this->_websiteMock->expects($this->any())->method('getCode')->will($this->returnValue($websiteCode));
     $this->_websiteMock->expects($this->at(3))->method('__call')->will($this->returnValue(true));
 }