/** * Initialize properties of object required for test. * * @return Mage_Backend_Block_System_Config_Form */ protected function _initObjects() { parent::_initObjects(); $this->_configData = $this->_configDataStub; if ($this->_configRootStub) { $this->_configRoot = $this->_configRootStub; } $this->_fieldRenderer = Mage::app()->getLayout()->createBlock('Mage_Backend_Block_System_Config_Form_Field'); }
/** * @dataProvider initFieldsDataProvider */ public function testInitFields($backendConfigValue, $xmlConfig, $configPath, $inherit, $expectedValue) { // Parameters initialization $fieldsetMock = $this->getMock('Varien_Data_Form_Element_Fieldset', array(), array(), '', false, false); $groupMock = $this->getMock('Mage_Backend_Model_Config_Structure_Element_Group', array(), array(), '', false, false); $sectionMock = $this->getMock('Mage_Backend_Model_Config_Structure_Element_Section', array(), array(), '', false, false); $fieldPrefix = 'fieldPrefix'; $labelPrefix = 'labelPrefix'; // Field Renderer Mock configuration $fieldRendererMock = $this->getMock('Mage_Backend_Block_System_Config_Form_Field', array(), array(), '', false, false); $this->_fieldFactoryMock->expects($this->once())->method('create')->will($this->returnValue($fieldRendererMock)); $this->_backendConfigMock->expects($this->once())->method('extendConfig')->with('some/config/path', false, array('section1/group1/field1' => 'some_value'))->will($this->returnValue($backendConfigValue)); $this->_coreConfigMock->expects($this->any())->method('getNode')->will($this->returnValue($xmlConfig)); // Field mock configuration $fieldMock = $this->getMock('Mage_Backend_Model_Config_Structure_Element_Field', array(), array(), '', false, false); $fieldMock->expects($this->any())->method('getPath')->will($this->returnValue('section1/group1/field1')); $fieldMock->expects($this->any())->method('getConfigPath')->will($this->returnValue($configPath)); $fieldMock->expects($this->any())->method('getGroupPath')->will($this->returnValue('some/config/path')); $fieldMock->expects($this->once())->method('getSectionId')->will($this->returnValue('some_section')); $fieldMock->expects($this->once())->method('hasBackendModel')->will($this->returnValue(false)); $fieldMock->expects($this->once())->method('getDependencies')->with($fieldPrefix)->will($this->returnValue(array())); $fieldMock->expects($this->any())->method('getType')->will($this->returnValue('field')); $fieldMock->expects($this->once())->method('getLabel')->will($this->returnValue('label')); $fieldMock->expects($this->once())->method('getComment')->will($this->returnValue('comment')); $fieldMock->expects($this->once())->method('getTooltip')->will($this->returnValue('tooltip')); $fieldMock->expects($this->once())->method('getHint')->will($this->returnValue('hint')); $fieldMock->expects($this->once())->method('getFrontendClass')->will($this->returnValue('frontClass')); $fieldMock->expects($this->once())->method('showInDefault')->will($this->returnValue(false)); $fieldMock->expects($this->any())->method('showInWebsite')->will($this->returnValue(false)); $fieldMock->expects($this->once())->method('getData')->will($this->returnValue('fieldData')); $fields = array($fieldMock); $groupMock->expects($this->once())->method('getChildren')->will($this->returnValue($fields)); $sectionMock->expects($this->once())->method('getId')->will($this->returnValue('section1')); $formFieldMock = $this->getMockForAbstractClass('Varien_Data_Form_Element_Abstract', array(), '', false, false, true, array('setRenderer')); $params = array('name' => 'groups[group1][fields][fieldPrefixfield1][value]', 'label' => 'label', 'comment' => 'comment', 'tooltip' => 'tooltip', 'hint' => 'hint', 'value' => $expectedValue, 'inherit' => $inherit, 'class' => 'frontClass', 'field_config' => 'fieldData', 'scope' => 'stores', 'scope_id' => 1, 'scope_label' => '[GLOBAL]', 'can_use_default_value' => false, 'can_use_website_value' => false); $formFieldMock->expects($this->once())->method('setRenderer')->with($fieldRendererMock); $fieldsetMock->expects($this->once())->method('addField')->with('section1_group1_field1', 'field', $params)->will($this->returnValue($formFieldMock)); $fieldMock->expects($this->once())->method('populateInput'); $this->_object->initFields($fieldsetMock, $groupMock, $sectionMock, $fieldPrefix, $labelPrefix); }