예제 #1
0
 public function testGetDependenciesWithDependencies()
 {
     $fields = ['field_4' => ['id' => 'section_2/group_3/field_4', 'value' => 'someValue', 'dependPath' => ['section_2', 'group_3', 'field_4']]];
     $this->_model->setData(['depends' => ['fields' => $fields]], 0);
     $this->_depMapperMock->expects($this->once())->method('getDependencies')->with($fields, 'test_scope')->will($this->returnArgument(0));
     $this->assertEquals($fields, $this->_model->getDependencies('test_scope'));
 }
예제 #2
0
 /**
  * @covers \Magento\Backend\Block\System\Config\Form::initFields
  * @param bool $useConfigField uses the test_field_use_config field if true
  * @param bool $isConfigDataEmpty if the config data array should be empty or not
  * @param $configDataValue the value that the field path should be set to in the config data
  * @dataProvider initFieldsUseConfigPathDataProvider
  * @magentoConfigFixture default/test_config_section/test_group_config_node/test_field_value config value
  */
 public function testInitFieldsUseConfigPath($useConfigField, $isConfigDataEmpty, $configDataValue)
 {
     $this->_setupFieldsInheritCheckbox($useConfigField, $isConfigDataEmpty, $configDataValue);
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\Config\\ScopeInterface')->setCurrentScope(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE);
     $form = $this->_formFactory->create();
     $fieldset = $form->addFieldset($this->_section->getId() . '_' . $this->_group->getId(), []);
     /* @TODO Eliminate stub by proper mock / config fixture usage */
     /** @var $block \Magento\Backend\Block\System\Config\FormStub */
     $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Backend\\Block\\System\\Config\\FormStub');
     $block->setScope(\Magento\Backend\Block\System\Config\Form::SCOPE_DEFAULT);
     $block->setStubConfigData($this->_configData);
     $block->initFields($fieldset, $this->_group, $this->_section);
     $fieldsetSel = 'fieldset';
     $valueSel = sprintf('input#%s_%s_%s', $this->_section->getId(), $this->_group->getId(), $this->_field->getId());
     $fieldsetHtml = $fieldset->getElementHtml();
     $this->assertSelectCount($fieldsetSel, true, $fieldsetHtml, 'Fieldset HTML is invalid');
     $this->assertSelectCount($valueSel, true, $fieldsetHtml, 'Field input not found in fieldset HTML');
 }
예제 #3
0
 /**
  * Initialize config group fields
  *
  * @param \Magento\Framework\Data\Form\Element\Fieldset $fieldset
  * @param \Magento\Backend\Model\Config\Structure\Element\Group $group
  * @param \Magento\Backend\Model\Config\Structure\Element\Section $section
  * @param string $fieldPrefix
  * @param string $labelPrefix
  * @return $this
  */
 public function initFields(\Magento\Framework\Data\Form\Element\Fieldset $fieldset, \Magento\Backend\Model\Config\Structure\Element\Group $group, \Magento\Backend\Model\Config\Structure\Element\Section $section, $fieldPrefix = '', $labelPrefix = '')
 {
     if (!$this->_configDataObject) {
         $this->_initObjects();
     }
     // Extends for config data
     $extraConfigGroups = [];
     /** @var $element \Magento\Backend\Model\Config\Structure\Element\Field */
     foreach ($group->getChildren() as $element) {
         if ($element instanceof \Magento\Backend\Model\Config\Structure\Element\Group) {
             $this->_initGroup($element, $section, $fieldset);
         } else {
             $path = $element->getConfigPath() ?: $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;
 }