Example #1
0
 /**
  * @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
  */
 protected function _setupFieldsInheritCheckbox($useConfigField, $isConfigDataEmpty, $configDataValue)
 {
     \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize([State::PARAM_BAN_CACHE => true]);
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\Config\\ScopeInterface')->setCurrentScope(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE);
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\AreaList')->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)->load(\Magento\Framework\App\Area::PART_CONFIG);
     $fileResolverMock = $this->getMockBuilder('Magento\\Framework\\App\\Config\\FileResolver')->disableOriginalConstructor()->getMock();
     $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\Filesystem');
     /** @var $directory  \Magento\Framework\Filesystem\Directory\Read */
     $directory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
     $fileIteratorFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\Config\\FileIteratorFactory');
     $fileIterator = $fileIteratorFactory->create($directory, [$directory->getRelativePath(__DIR__ . '/_files/test_section_config.xml')]);
     $fileResolverMock->expects($this->any())->method('get')->will($this->returnValue($fileIterator));
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $structureReader = $objectManager->create('Magento\\Backend\\Model\\Config\\Structure\\Reader', ['fileResolver' => $fileResolverMock]);
     $structureData = $objectManager->create('Magento\\Backend\\Model\\Config\\Structure\\Data', ['reader' => $structureReader]);
     /** @var \Magento\Backend\Model\Config\Structure $structure  */
     $structure = $objectManager->create('Magento\\Backend\\Model\\Config\\Structure', ['structureData' => $structureData]);
     $this->_section = $structure->getElement('test_section');
     $this->_group = $structure->getElement('test_section/test_group');
     if ($useConfigField) {
         $this->_field = $structure->getElement('test_section/test_group/test_field_use_config');
     } else {
         $this->_field = $structure->getElement('test_section/test_group/test_field');
     }
     $fieldPath = $this->_field->getConfigPath();
     if ($isConfigDataEmpty) {
         $this->_configData = [];
     } else {
         $this->_configData = [$fieldPath => $configDataValue];
     }
 }
Example #2
0
 /**
  * Get css class for "shared" functionality
  *
  * @param \Magento\Backend\Model\Config\Structure\Element\Field $field
  * @return string
  */
 protected function _getSharedCssClass(\Magento\Backend\Model\Config\Structure\Element\Field $field)
 {
     $sharedClass = '';
     if ($field->getAttribute('shared') && $field->getConfigPath()) {
         $sharedClass = ' shared shared-' . str_replace('/', '-', $field->getConfigPath());
         return $sharedClass;
     }
     return $sharedClass;
 }
Example #3
0
 public function testGetConfigPath()
 {
     $this->_model->setData(array('config_path' => 'custom_config_path'), 'scope');
     $this->assertEquals('custom_config_path', $this->_model->getConfigPath());
 }