KnpMarkdownBundle/tests/EscapingTest.php

50 lines
1,021 B
PHP
Raw Normal View History

<?php
namespace Knp\Bundle\MarkdownBundle\Tests;
2021-11-08 12:24:51 +01:00
use PHPUnit\Framework\TestCase;
use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser as Parser;
2021-11-08 12:24:51 +01:00
class EscapingTest extends TestCase
{
protected $parser;
2021-11-08 12:24:51 +01:00
public function setUp(): void
{
$this->parser = new Parser();
}
public function testHtmlEscaping()
{
$this->markTestIncomplete('This tests a very deep escaping capability of the wrapped library @todo');
2012-02-25 12:06:40 +01:00
$text = <<<EOF
<a>a tag injection</a>
EOF;
2012-02-25 12:06:40 +01:00
$html = <<<EOF
<p>&lt;a&gt;a tag injection&lt;/a&gt;</p>
EOF;
$this->assertEquals($html, $this->parser->transform($text));
}
public function testScriptEscaping()
{
$this->markTestIncomplete('This tests a very deep escaping capability of the wrapped library @todo');
2012-02-25 12:06:40 +01:00
$text = <<<EOF
<script>alert("haha");</script>
EOF;
$html = <<<EOF
&lt;script&gt;alert("haha");&lt;/script&gt;
EOF;
2012-02-25 12:06:40 +01:00
$this->assertEquals($html, $this->parser->transform($text));
}
}