/** * @param string $attribute * @return void * @expectedException \InvalidArgumentException * @dataProvider setAttributeArgumentExceptionDataProvider */ public function testSetAttributeArgumentException($attribute) { $this->_structure->importElements(['element' => []]); $this->_structure->setAttribute('element', $attribute, 'value'); }
/** * Set container-specific data to structure element * * @param string $name * @param string $label * @param array $options * @return void * @throws \Magento\Framework\Exception If any of arguments are invalid */ protected function _generateContainer($name, $label, array $options) { $this->_structure->setAttribute($name, Element::CONTAINER_OPT_LABEL, $label); unset($options[Element::CONTAINER_OPT_LABEL]); unset($options['type']); $allowedTags = array('dd', 'div', 'dl', 'fieldset', 'header', 'footer', 'hgroup', 'ol', 'p', 'section', 'table', 'tfoot', 'ul'); if (!empty($options[Element::CONTAINER_OPT_HTML_TAG]) && !in_array($options[Element::CONTAINER_OPT_HTML_TAG], $allowedTags)) { throw new \Magento\Framework\Exception(__('Html tag "%1" is forbidden for usage in containers. Consider to use one of the allowed: %2.', $options[Element::CONTAINER_OPT_HTML_TAG], implode(', ', $allowedTags))); } if (empty($options[Element::CONTAINER_OPT_HTML_TAG]) && (!empty($options[Element::CONTAINER_OPT_HTML_ID]) || !empty($options[Element::CONTAINER_OPT_HTML_CLASS]))) { throw new \Magento\Framework\Exception('HTML ID or class will not have effect, if HTML tag is not specified.'); } foreach ($options as $key => $value) { $this->_structure->setAttribute($name, $key, $value); } }