public function testIsVisibleProceedsWithVisibilityCheckIfSectionIsAllowed() { $this->_authorizationMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); $this->_storeManagerMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); $this->_model->setData(['resource' => 'Magento_Adminhtml::all'], 'scope'); $this->_model->isVisible(); }
/** * @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'); }
/** * Check whether section should be displayed as active * * @param \Magento\Backend\Model\Config\Structure\Element\Section $section * @return bool */ public function isSectionActive(\Magento\Backend\Model\Config\Structure\Element\Section $section) { return $section->getId() == $this->_currentSectionId; }