Пример #1
0
 public function testSaveToCheckScopeDataSet()
 {
     $transactionMock = $this->getMock('Magento\\Framework\\DB\\Transaction', array(), array(), '', false);
     $this->_transFactoryMock->expects($this->any())->method('create')->will($this->returnValue($transactionMock));
     $this->_configLoaderMock->expects($this->any())->method('getConfigByPath')->will($this->returnValue(array()));
     $this->_eventManagerMock->expects($this->at(0))->method('dispatch')->with($this->equalTo('admin_system_config_changed_section_'), $this->arrayHasKey('website'));
     $this->_eventManagerMock->expects($this->at(0))->method('dispatch')->with($this->equalTo('admin_system_config_changed_section_'), $this->arrayHasKey('store'));
     $group = $this->getMock('Magento\\Backend\\Model\\Config\\Structure\\Element\\Group', array(), array(), '', false);
     $field = $this->getMock('Magento\\Backend\\Model\\Config\\Structure\\Element\\Field', array(), array(), '', false);
     $this->_configStructure->expects($this->at(0))->method('getElement')->with('/1')->will($this->returnValue($group));
     $this->_configStructure->expects($this->at(1))->method('getElement')->with('/1/key')->will($this->returnValue($field));
     $website = $this->getMock('Magento\\Store\\Model\\Website', array(), array(), '', false);
     $this->_storeManager->expects($this->any())->method('getWebsite')->will($this->returnValue($website));
     $this->_storeManager->expects($this->any())->method('getWebsites')->will($this->returnValue(array($website)));
     $this->_storeManager->expects($this->any())->method('isSingleStoreMode')->will($this->returnValue(true));
     $this->_model->setWebsite('website');
     $this->_model->setGroups(array('1' => array('fields' => array('key' => array('data')))));
     $backendModel = $this->getMock('Magento\\Framework\\App\\Config\\Value', array('setPath', 'addData', '__sleep', '__wakeup'), array(), '', false);
     $backendModel->expects($this->once())->method('addData')->with(array('field' => 'key', 'groups' => array(1 => array('fields' => array('key' => array('data')))), 'group_id' => null, 'scope' => 'websites', 'scope_id' => 0, 'scope_code' => 'website', 'field_config' => null, 'fieldset_data' => array('key' => null)));
     $backendModel->expects($this->once())->method('setPath')->with('/key')->will($this->returnValue($backendModel));
     $this->_dataFactoryMock->expects($this->any())->method('create')->will($this->returnValue($backendModel));
     $this->_model->save();
 }