public function testIsEnabled() { $this->assertEmpty($this->model->isEnabled()); $this->model->setData('wysiwyg', true); $this->assertTrue($this->model->isEnabled()); $this->model->unsetData('wysiwyg'); $this->configMock->expects($this->once())->method('getData')->with('enabled')->willReturn(true); $this->assertTrue($this->model->isEnabled()); }
/** * Wysiwyg constructor. * @param ContextInterface $context * @param Form $form * @param EditorElement $editorElement * @param ConfigInterface $wysiwygConfig * @param array $components * @param array $data */ public function __construct(ContextInterface $context, Form $form, EditorElement $editorElement, ConfigInterface $wysiwygConfig, array $components = [], array $data = []) { $this->editorElement = $editorElement; $this->editorElement->setForm($form); $this->editorElement->setData('force_load', true); $this->editorElement->setData('rows', 20); $this->editorElement->setData('name', $data['name']); $this->editorElement->setData('html_id', $data['name'] . 'Editor'); $this->editorElement->setConfig($wysiwygConfig->getConfig()); $data['config']['content'] = $editorElement->getElementHtml(); parent::__construct($context, $components, $data); }
/** * @param bool $expected * @param bool $globalFlag * @param bool $attributeFlag * @dataProvider isEnabledDataProvider * @return void */ public function testIsEnabled($expected, $globalFlag, $attributeFlag = null) { $this->configMock->expects($this->once())->method('getData')->with('enabled')->willReturn($globalFlag); if ($attributeFlag !== null) { $this->model->setData('wysiwyg', $attributeFlag); } $this->assertEquals($expected, $this->model->isEnabled()); }
/** * Wysiwyg constructor. * @param ContextInterface $context * @param Form $form * @param EditorElement $editorElement * @param ConfigInterface $wysiwygConfig * @param LayoutInterface $layout * @param DataHelper $backendHelper * @param CategoryAttributeRepositoryInterface $attrRepository * @param array $components * @param array $data * @param array $config * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct(ContextInterface $context, Form $form, EditorElement $editorElement, ConfigInterface $wysiwygConfig, LayoutInterface $layout, DataHelper $backendHelper, CategoryAttributeRepositoryInterface $attrRepository, array $components = [], array $data = [], array $config = []) { $this->layout = $layout; $this->backendHelper = $backendHelper; $editorElement->setData('wysiwyg', (bool) $attrRepository->get($data['name'])->getIsWysiwygEnabled()); parent::__construct($context, $form, $editorElement, $wysiwygConfig, $components, $data, $config); $this->setData($this->prepareData($this->getData())); }