'text',
'text' => 'Text',
];
/** @var pQuery */
private $parser;
public function _before() {
parent::_before();
$this->parser = new pQuery;
}
public function testItRendersPlainText() {
$output = (new Text)->render($this->block);
$expectedResult = '
Text
|
';
expect($output)->equals($expectedResult);
}
public function testItRendersParagraph() {
$this->block['text'] = 'Text
';
$output = (new Text)->render($this->block);
$table = $this->parser->parseStr($output)->query('table');
$this->assertInstanceOf(pQuery::class, $table);
$tableElement = $table[0];
$this->assertInstanceOf(DomNode::class, $tableElement);
$paragraphTable = $tableElement->toString();
$expectedResult = '';
expect($paragraphTable)->equals($expectedResult);
}
public function testItRendersNewLinesBetweenWordPressParagraphs(): void {
$this->block['text'] = '
First
Second
';
$output = (new Text)->render($this->block);
$table = $this->parser->parseStr($output)->query('table');
$this->assertInstanceOf(pQuery::class, $table);
$tableElement = $table[0];
$this->assertInstanceOf(DomNode::class, $tableElement);
$paragraphTable = $tableElement->toString();
$expectedResult = '';
expect($paragraphTable)->equals($expectedResult);
$tableElement = $table[1];
$this->assertInstanceOf(DomNode::class, $tableElement);
$paragraphTable = $tableElement->toString();
$expectedResult = '';
expect($paragraphTable)->equals($expectedResult);
}
public function testItRendersNewLinesWordPressParagraphAndHeading(): void {
$this->block['text'] = '
First
Second
';
$output = (new Text)->render($this->block);
$table = $this->parser->parseStr($output)->query('table');
$this->assertInstanceOf(pQuery::class, $table);
$tableElement = $table[0];
$this->assertInstanceOf(DomNode::class, $tableElement);
$paragraphTable = $tableElement->toString();
$expectedResult = '';
expect($paragraphTable)->equals($expectedResult);
$heading = $this->parser->parseStr($output)->query('h1');
$this->assertInstanceOf(pQuery::class, $heading);
$headingElement = $heading[0];
$this->assertInstanceOf(DomNode::class, $headingElement);
$heading = $headingElement->toString();
$expectedResult = 'Second
';
expect($heading)->equals($expectedResult);
}
public function testItRendersList() {
$this->block['text'] = '';
$output = (new Text)->render($this->block);
$ul = $this->parser->parseStr($output)->query('ul');
$this->assertInstanceOf(pQuery::class, $ul);
$ulElement = $ul[0];
$this->assertInstanceOf(DomNode::class, $ulElement);
$list = $ulElement->toString();
$expectedResult = '';
expect($list)->equals($expectedResult);
}
public function testItRendersBlockquotes() {
$this->block['text'] = 'Quote
';
$output = (new Text)->render($this->block);
$table = $this->parser->parseStr($output)->query('table');
$this->assertInstanceOf(pQuery::class, $table);
$tableElement = $table[0];
$this->assertInstanceOf(DomNode::class, $tableElement);
$blockquoteTable = $tableElement->toString();
$expectedResult = '';
expect($blockquoteTable)->equals($expectedResult);
}
public function testItShouldRemoveEmptyParagraphs() {
$this->block['text'] = 'Text
Text2
';
$output = (new Text)->render($this->block);
$expectedResult = '
|
';
expect($output)->equals($expectedResult);
}
public function testItStylesHeadings() {
$this->block['text'] = 'Heading
Heading 2
';
$output = (new Text)->render($this->block);
expect($output)->stringContainsString('Heading
');
expect($output)->stringContainsString('Heading 2
');
}
public function testItStylesHeadingsCenter() {
$this->block['text'] = 'Let\'s Get Started!
';
$output = (new Text)->render($this->block);
expect($output)->stringContainsString('Text <script>alert('test');</script>"],
'list' => ["Text <script>alert('test');</script>
"],
'blockquote' => ["Text <script>alert('test');</script>
"],
];
}
/**
* @dataProvider htmlEntitiesStrings
*/
public function testItDoesNotDecodeHtmlEntities($htmlString) {
$this->block['text'] = $htmlString;
$output = (new Text())->render($this->block);
expect($output)->stringNotContainsString('