public function testSaveEmptiesNonSetArguments() { $this->_structureReaderMock->expects($this->never())->method('getConfiguration'); $this->assertNull($this->_model->getSection()); $this->assertNull($this->_model->getWebsite()); $this->assertNull($this->_model->getStore()); $this->_model->save(); $this->assertSame('', $this->_model->getSection()); $this->assertSame('', $this->_model->getWebsite()); $this->assertSame('', $this->_model->getStore()); }
/** * Init fieldset fields * * @param Varien_Data_Form_Element_Fieldset $fieldset * @param array $group * @param array $section * @param string $fieldPrefix * @param string $labelPrefix * @return Mage_Backend_Block_System_Config_Form */ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '') { if (!$this->_configDataObject) { $this->_initObjects(); } // Extends for config data $configDataAdditionalGroups = array(); $fields = isset($group['fields']) ? $group['fields'] : array(); /** @var array $elements */ // sort either by sortOrder or by child node values by passing the sortOrder $elements = $this->_sortElements($group, $fieldset, $fields); foreach ($elements as $element) { if (false == $this->_canShowField($element)) { continue; } /** * Look for custom defined field path */ $path = isset($element['config_path']) ? $element['config_path'] : ''; if (empty($path)) { $path = $section['id'] . '/' . $group['id'] . '/' . $fieldPrefix . $element['id']; } elseif (strrpos($path, '/') > 0) { // Extend config data with new section group $groupPath = substr($path, 0, strrpos($path, '/')); if (false == isset($configDataAdditionalGroups[$groupPath])) { $this->_configData = $this->_configDataObject->extendConfig($groupPath, false, $this->_configData); $configDataAdditionalGroups[$groupPath] = true; } } $this->_initElement($element, $fieldset, $group, $section, $path, $fieldPrefix, $labelPrefix); } return $this; }
/** * Initialize config group fields * * @param Varien_Data_Form_Element_Fieldset $fieldset * @param Mage_Backend_Model_Config_Structure_Element_Group $group * @param Mage_Backend_Model_Config_Structure_Element_Section $section * @param string $fieldPrefix * @param string $labelPrefix * @return Mage_Backend_Block_System_Config_Form */ public function initFields(Varien_Data_Form_Element_Fieldset $fieldset, Mage_Backend_Model_Config_Structure_Element_Group $group, Mage_Backend_Model_Config_Structure_Element_Section $section, $fieldPrefix = '', $labelPrefix = '') { if (!$this->_configDataObject) { $this->_initObjects(); } // Extends for config data $extraConfigGroups = array(); /** @var $element Mage_Backend_Model_Config_Structure_Element_Field */ foreach ($group->getChildren() as $element) { if ($element instanceof Mage_Backend_Model_Config_Structure_Element_Group) { $this->_initGroup($element, $section, $fieldset); } else { $path = $element->getPath($fieldPrefix); if ($element->getSectionId() != $section->getId()) { $groupPath = $element->getGroupPath(); if (!isset($extraConfigGroups[$groupPath])) { $this->_configData = $this->_configDataObject->extendConfig($groupPath, false, $this->_configData); $extraConfigGroups[$groupPath] = true; } } $this->_initElement($element, $fieldset, $path, $fieldPrefix, $labelPrefix); } } return $this; }