81 lines
2.7 KiB
PHP
81 lines
2.7 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../../buttons/DquotesButton.php';
|
|
|
|
/**
|
|
* Class DquotesButtonTest
|
|
*/
|
|
class DquotesButtonTest extends PHPUnit_Framework_TestCase
|
|
{
|
|
/**
|
|
* @var DquotesButton
|
|
*/
|
|
protected $button;
|
|
|
|
/**
|
|
* Set up
|
|
*/
|
|
public function setUp()
|
|
{
|
|
$this->button = new DquotesButton('serendipity[body]');
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
* @dataProvider getNamedEntities
|
|
*/
|
|
public function render($type, $openTag, $closeTag, $namedEntity)
|
|
{
|
|
$this->button->setType($type);
|
|
$html = sprintf(
|
|
'<button class="wrap_selection" type="button" name="insdquote" data-tag-open="%s" data-tag-close="%s" data-tarea="serendipity[body]">%s</button>',
|
|
$openTag,
|
|
$closeTag,
|
|
$namedEntity
|
|
);
|
|
$expected = ' ' . $html . PHP_EOL;
|
|
$this->assertEquals($expected, $this->button->render());
|
|
}
|
|
|
|
/**
|
|
* Data provider for named entities
|
|
*
|
|
* @return array
|
|
*/
|
|
public function getNamedEntities()
|
|
{
|
|
return array(
|
|
array('type1', '“', '”', '“ ”'),
|
|
array('type2', '„', '“', '„ “'),
|
|
array('type3', '„', '”', '„ ”'),
|
|
array('type4', '”', '”', '” ”'),
|
|
array('type5', '“', '„', '“ „'),
|
|
array('type6', '« ', ' »', '« »'),
|
|
array('type7', '»', '«', '» «'),
|
|
array('type8', '»', '»', '» »'),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function renderInLegacyMode()
|
|
{
|
|
$this->button->setIsLegacyMode(true);
|
|
$this->button->setType('type1');
|
|
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="“ ”" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&ldquo\\;\',\'\\&rdquo\\;\')" />' . PHP_EOL;
|
|
$this->assertEquals($expected, $this->button->render());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function renderInLegacyModeNoNamedEnts()
|
|
{
|
|
$this->button->setIsLegacyMode(true);
|
|
$this->button->setUseNamedEnts(false);
|
|
$this->button->setType('type1');
|
|
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="“ ”" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&\\#8220\\;\',\'\\&\\#8221\\;\')" />' . PHP_EOL;
|
|
$this->assertEquals($expected, $this->button->render());
|
|
}
|
|
|
|
}
|