/** * @test * @dataProvider getCustomData */ public function renderInLegacyMode($name, $openTag, $closeTag) { $this->button->setIsLegacyMode(true); $this->button->setName('ins_custom_' . $name); $this->button->setValue($name); $this->button->setOpen($openTag); $this->button->setClose($closeTag); $expected = ' <input type="button" class="serendipityPrettyButton input_button" name="ins_custom_' . $name . '" value="' . $name . '" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'' . $openTag . '\', \'' . $closeTag . '\')" />' . PHP_EOL; $this->assertEquals($expected, $this->button->render()); }
/** * @param string $txtarea * @param string $part * @return string */ private function getCustomButton($txtarea, $part) { $buttons = explode('@', $part); $b_name = function_exists('serendipity_specialchars') ? serendipity_specialchars($buttons[0]) : htmlspecialchars($buttons[0], ENT_COMPAT, LANG_CHARSET); $b_title = preg_replace('@[^a-z0-9]@i', '_', $buttons[0]); $b_open = str_replace(array('"', "'"), array('"', "\\'"), $buttons[1]); $b_close = str_replace(array('"', "'"), array('"', "\\'"), $buttons[2]); require_once 'buttons/CustomButton.php'; $button = new CustomButton($txtarea); $button->setIsLegacyMode($this->legacy); $button->setName('ins_custom_' . $b_name); $button->setValue($b_title); $button->setOpen($b_open); $button->setClose($b_close); return $button->render(); }