Esempio n. 1
0
 /**
  * @dataProvider readDataProvider
  * @param string|null $storeCode
  * @param string $storeMethod
  */
 public function testRead($storeCode, $storeMethod)
 {
     $websiteCode = 'default';
     $storeId = 1;
     $defaultStoreCode = 'foostore';
     $defaultStoreId = 2;
     $websiteMock = $this->getMock('Magento\\Store\\Model\\Website', [], [], '', false);
     $websiteMock->expects($this->any())->method('getCode')->will($this->returnValue($websiteCode));
     $this->_storeMock->expects($this->any())->method('getWebsite')->will($this->returnValue($websiteMock));
     $this->_storeMock->expects($this->any())->method('load')->with($storeCode);
     $this->_storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId));
     $this->_storeMock->expects($this->any())->method('getCode')->will($this->returnValue($websiteCode));
     $this->_defaultStoreMock->expects($this->any())->method('getWebsite')->will($this->returnValue($websiteMock));
     $this->_defaultStoreMock->expects($this->any())->method('load')->with($defaultStoreCode);
     $this->_defaultStoreMock->expects($this->any())->method('getId')->will($this->returnValue($defaultStoreId));
     $this->_defaultStoreMock->expects($this->any())->method('getCode')->will($this->returnValue($defaultStoreCode));
     $dataMock = $this->getMock('Magento\\Framework\\App\\Config\\Data', [], [], '', false);
     $dataMock->expects($this->any())->method('getValue')->will($this->returnValue(['config' => ['key0' => 'website_value0', 'key1' => 'website_value1']]));
     $dataMock->expects($this->once())->method('getSource')->will($this->returnValue(['config' => ['key0' => 'website_value0', 'key1' => 'website_value1']]));
     $this->_scopePullMock->expects($this->once())->method('getScope')->with('website', $websiteCode)->will($this->returnValue($dataMock));
     $this->_initialConfigMock->expects($this->once())->method('getData')->with("stores|{$storeCode}")->will($this->returnValue(['config' => ['key1' => 'store_value1', 'key2' => 'store_value2']]));
     $this->_collectionFactory->expects($this->once())->method('create')->with(['scope' => 'stores', 'scopeId' => $storeId])->will($this->returnValue([new Object(['path' => 'config/key1', 'value' => 'store_db_value1']), new Object(['path' => 'config/key3', 'value' => 'store_db_value3'])]));
     $this->_storeManagerMock->expects($this->any())->method('getDefaultStoreView')->will($this->returnValue($this->_defaultStoreMock));
     $this->_storeManagerMock->expects($this->any())->method($storeMethod)->will($this->returnValue($this->_storeMock));
     $expectedData = ['config' => ['key0' => 'website_value0', 'key1' => 'store_db_value1', 'key2' => 'store_value2', 'key3' => 'store_db_value3']];
     $this->assertEquals($expectedData, $this->_model->read($storeCode));
 }
Esempio n. 2
0
 /**
  * @param mixed $configValue
  * @param bool $expectedResult
  * @dataProvider isSetFlagDataProvider
  */
 public function testIsSetFlag($configValue, $expectedResult)
 {
     $path = 'some path';
     $configData = $this->getConfigDataMock('getValue');
     $configData->expects($this->once())->method('getValue')->with($this->equalTo($path))->will($this->returnValue($configValue));
     $this->sectionPool->expects($this->once())->method('getScope')->with($this->equalTo('default'), $this->isNull())->will($this->returnValue($configData));
     $this->assertEquals($expectedResult, $this->model->isSetFlag($path));
 }
Esempio n. 3
0
 public function testRead()
 {
     $websiteCode = 'default';
     $websiteId = 1;
     $dataMock = $this->getMock('Magento\\Framework\\App\\Config\\Data', [], [], '', false);
     $dataMock->expects($this->any())->method('getValue')->will($this->returnValue(['config' => ['key0' => 'default_value0', 'key1' => 'default_value1']]));
     $dataMock->expects($this->once())->method('getSource')->will($this->returnValue(['config' => ['key0' => 'default_value0', 'key1' => 'default_value1']]));
     $this->_scopePullMock->expects($this->once())->method('getScope')->with('default', null)->will($this->returnValue($dataMock));
     $this->_initialConfigMock->expects($this->any())->method('getData')->with("websites|{$websiteCode}")->will($this->returnValue(['config' => ['key1' => 'website_value1', 'key2' => 'website_value2']]));
     $this->_websiteMock->expects($this->once())->method('load')->with($websiteCode);
     $this->_websiteMock->expects($this->any())->method('getId')->will($this->returnValue($websiteId));
     $this->_collectionFactory->expects($this->once())->method('create')->with(['scope' => 'websites', 'scopeId' => $websiteId])->will($this->returnValue([new \Magento\Framework\Object(['path' => 'config/key1', 'value' => 'website_db_value1']), new \Magento\Framework\Object(['path' => 'config/key3', 'value' => 'website_db_value3'])]));
     $expectedData = ['config' => ['key0' => 'default_value0', 'key1' => 'website_db_value1', 'key2' => 'website_value2', 'key3' => 'website_db_value3']];
     $this->assertEquals($expectedData, $this->_model->read($websiteCode));
 }