From e83231ad1d1ab2853f45aca0e724b1c916575e15 Mon Sep 17 00:00:00 2001 From: Jason Ng <116290832+jason490@users.noreply.github.com> Date: Sun, 19 Nov 2023 22:12:47 -0500 Subject: [PATCH] Removed unneeded tests --- .../GithubMarkdownEngineTest.php | 50 --------------- .../MarkdownEngine/ParsedownEngineTest.php | 61 ------------------- .../PHPLeagueMarkdownEngineTest.php | 6 +- .../TokenParser/MarkdownTokenParserTest.php | 4 +- 4 files changed, 5 insertions(+), 116 deletions(-) delete mode 100644 tests/Submitty/Twig/Extension/MarkdownEngine/GithubMarkdownEngineTest.php delete mode 100644 tests/Submitty/Twig/Extension/MarkdownEngine/ParsedownEngineTest.php rename tests/Submitty/Twig/Extension/{MarkdownEngine => }/PHPLeagueMarkdownEngineTest.php (68%) diff --git a/tests/Submitty/Twig/Extension/MarkdownEngine/GithubMarkdownEngineTest.php b/tests/Submitty/Twig/Extension/MarkdownEngine/GithubMarkdownEngineTest.php deleted file mode 100644 index 91c59a7..0000000 --- a/tests/Submitty/Twig/Extension/MarkdownEngine/GithubMarkdownEngineTest.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -class GitHubMarkdownEngineTest extends MarkdownExtensionTest -{ - /** - * @dataProvider getParseMarkdownTests - */ - public function testParseMarkdown($template, $expected, $context = array()) - { - try { - $this->assertEquals($expected, $this->getTemplate($template)->render($context)); - } catch (\Exception $e) { - $this->markTestSkipped($e->getMessage()); - } - } - - public function getParseMarkdownTests() - { - return array( - array('{{ "# Main Title"|markdown }}', '

Main Title

'), - array('{{ content|markdown }}', '

Main Title

', array('content' => '# Main Title')), - // Check if GFM is working - array('{{ "@aptoma"|markdown }}', - '

@aptoma

'), - ); - } - - protected function getEngine() - { - $client = new Client(); - - if ($client->rateLimit()->getResource('core')->getLimit() < 1) { - $this->markTestSkipped('The github API rate limit is reached, so this engine cannot be tested.'); - } - - return new GitHubMarkdownEngine(); - } -} diff --git a/tests/Submitty/Twig/Extension/MarkdownEngine/ParsedownEngineTest.php b/tests/Submitty/Twig/Extension/MarkdownEngine/ParsedownEngineTest.php deleted file mode 100644 index 78faff3..0000000 --- a/tests/Submitty/Twig/Extension/MarkdownEngine/ParsedownEngineTest.php +++ /dev/null @@ -1,61 +0,0 @@ - - */ -class ParsedownEngineTest extends MarkdownExtensionTest -{ - public function getParseMarkdownTests() - { - return array( - array('{{ "# Main Title"|markdown }}', '

Main Title

'), - array('{{ content|markdown }}', '

Main Title

', array('content' => '# Main Title')), - array('{% markdown %}{{ content }}{% endmarkdown %}', '

Main Title

', array('content' => '# Main Title')) - ); - } - - protected function getEngine() - { - return new ParsedownEngine(); - } - - public function testSafeMode() - { - $engine = $this->getEngine(); - $loader = new \Twig\Loader\ArrayLoader(array('index' => '{{ "_Test_Test[xss](javascript:alert%281%29)"|markdown }}')); - $twig = new \Twig\Environment($loader, array('debug' => true, 'cache' => false)); - $twig->addExtension(new MarkdownExtension($engine)); - - $this->assertEquals('

TestTestxss

', $twig->load('index')->render()); - - $engine->setSafeMode(true); - $this->assertEquals('

Test<em>Test</em>xss

', $twig->load('index')->render()); - $engine->setSafeMode(false); - } - - public function testMarkupEscape() - { - $engine = $this->getEngine(); - $loader = new \Twig\Loader\ArrayLoader(array('index' => '{{ "_Test_Test[xss](javascript:alert%281%29)"|markdown }}')); - $twig = new \Twig\Environment($loader, array('debug' => true, 'cache' => false)); - $twig->addExtension(new MarkdownExtension($engine)); - - $this->assertEquals('

TestTestxss

', $twig->load('index')->render()); - - $engine->setMarkupEscaped(true); - $this->assertEquals('

Test<em>Test</em>xss

', $twig->load('index')->render()); - $engine->setMarkupEscaped(false); - } -} diff --git a/tests/Submitty/Twig/Extension/MarkdownEngine/PHPLeagueMarkdownEngineTest.php b/tests/Submitty/Twig/Extension/PHPLeagueMarkdownEngineTest.php similarity index 68% rename from tests/Submitty/Twig/Extension/MarkdownEngine/PHPLeagueMarkdownEngineTest.php rename to tests/Submitty/Twig/Extension/PHPLeagueMarkdownEngineTest.php index 351d639..c62cda5 100644 --- a/tests/Submitty/Twig/Extension/MarkdownEngine/PHPLeagueMarkdownEngineTest.php +++ b/tests/Submitty/Twig/Extension/PHPLeagueMarkdownEngineTest.php @@ -5,16 +5,16 @@ use Submitty\Twig\Extension\MarkdownExtensionTest; // Require parent class if not autoloaded -if (!class_exists('\Aptoma\Twig\Extension\MarkdownExtensionTest')) { +if (!class_exists('\Submitty\Twig\Extension\MarkdownExtensionTest')) { require_once(__DIR__ . '/../MarkdownExtensionTest.php'); } /** - * Class PHPLeagueCommonMarkEngineTest + * Class PHPLeagueMarkdownEngineTest * * @author Casey McLaughlin */ -class PHPLeagueCommonMarkEngineTest extends MarkdownExtensionTest +class PHPLeagueMarkdownEngineTest extends MarkdownExtensionTest { protected function getEngine() { diff --git a/tests/Submitty/Twig/TokenParser/MarkdownTokenParserTest.php b/tests/Submitty/Twig/TokenParser/MarkdownTokenParserTest.php index f438e53..51fece0 100644 --- a/tests/Submitty/Twig/TokenParser/MarkdownTokenParserTest.php +++ b/tests/Submitty/Twig/TokenParser/MarkdownTokenParserTest.php @@ -85,7 +85,7 @@ public function getTests() \$lines = explode("\\n", \$content); \$content = preg_replace('/^' . \$matches[0]. '/', "", \$lines); \$content = join("\\n", \$content); -echo \$this->env->getExtension('Aptoma\Twig\Extension\MarkdownExtension')->parseMarkdown(\$content); +echo \$this->env->getExtension('Submitty\Twig\Extension\MarkdownExtension')->parseMarkdown(\$content); EOF ); @@ -106,7 +106,7 @@ public function getTests() \$lines = explode("\\n", \$content); \$content = preg_replace('/^' . \$matches[0]. '/', "", \$lines); \$content = join("\\n", \$content); -echo \$this->env->getExtension('Aptoma\Twig\Extension\MarkdownExtension')->parseMarkdown(\$content); +echo \$this->env->getExtension('Submitty\Twig\Extension\MarkdownExtension')->parseMarkdown(\$content); EOF );