Esempio n. 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'));
 }
Esempio n. 2
0
 /**
  * @covers \Magento\Config\Block\System\Config\Form::initFields
  * @param string $fieldId uses the test_field_use_config field if true
  * @param bool $isConfigDataEmpty if the config data array should be empty or not
  * @param string $configDataValue Value that the field path should be set to in the config data
  * @param int $valueSelCtr Number of time that value is selected
  * @dataProvider initFieldsUseConfigPathDataProvider
  * @magentoConfigFixture default/test_config_section/test_group_config_node/test_field_value config value
  */
 public function testInitFieldsUseConfigPath($fieldId, $isConfigDataEmpty, $configDataValue, $valueSelCtr = 1)
 {
     $this->_setupFieldsInheritCheckbox($fieldId, $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\Config\Block\System\Config\FormStub */
     $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Config\\Block\\System\\Config\\FormStub');
     $block->setScope(\Magento\Config\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, $valueSelCtr, $fieldsetHtml, 'Field input should appear ' . $valueSelCtr . ' times in fieldset HTML');
 }
Esempio n. 3
0
 /**
  * Initialize config group fields
  *
  * @param \Magento\Framework\Data\Form\Element\Fieldset $fieldset
  * @param \Magento\Config\Model\Config\Structure\Element\Group $group
  * @param \Magento\Config\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\Config\Model\Config\Structure\Element\Group $group, \Magento\Config\Model\Config\Structure\Element\Section $section, $fieldPrefix = '', $labelPrefix = '')
 {
     if (!$this->_configDataObject) {
         $this->_initObjects();
     }
     // Extends for config data
     $extraConfigGroups = [];
     /** @var $element \Magento\Config\Model\Config\Structure\Element\Field */
     foreach ($group->getChildren() as $element) {
         if ($element instanceof \Magento\Config\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;
 }
Esempio n. 4
0
 /**
  * Group constructor.
  *
  * @param StoreManagerInterface $storeManager      The store manager
  * @param Manager               $moduleManager     The module manager
  * @param FieldIterator         $childrenIterator  The children iterator
  * @param Factory               $cloneModelFactory The clone model factory
  * @param Mapper                $dependencyMapper  The dependency mapper
  * @param Visibility            $visibility        The visibility manager
  */
 public function __construct(StoreManagerInterface $storeManager, Manager $moduleManager, FieldIterator $childrenIterator, Factory $cloneModelFactory, Mapper $dependencyMapper, Visibility $visibility)
 {
     $this->visibility = $visibility;
     parent::__construct($storeManager, $moduleManager, $childrenIterator, $cloneModelFactory, $dependencyMapper);
 }