mirror of
https://github.com/KnpLabs/KnpMarkdownBundle.git
synced 2024-05-17 21:06:32 +02:00
Various test fixes: new versions of Michelf, etc
This commit is contained in:
parent
91a268692e
commit
02d9f8b7a4
|
@ -749,31 +749,15 @@ That's some text with a footnote.[^1]
|
|||
[^1]: And that's the footnote.
|
||||
EOF;
|
||||
|
||||
$html = <<<EOF
|
||||
<p>That's some text with a footnote.<sup id="fnref:1"><a href="#fn:1" class="footnote-ref">1</a></sup></p>
|
||||
|
||||
<div class="footnotes">
|
||||
<hr />
|
||||
<ol>
|
||||
|
||||
<li id="fn:1">
|
||||
<p>And that's the footnote. <a href="#fnref:1" class="footnote-backref">↩︎</a></p>
|
||||
</li>
|
||||
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
EOF;
|
||||
|
||||
// newer versions of Michelf add an extra ︎ To make the tests
|
||||
// pass against ALL versions, we just hack the ︎ into the
|
||||
// expected string if it isn't there
|
||||
$actualHtml = $parser->transform($text);
|
||||
if (strpos($actualHtml, '︎') === false) {
|
||||
$actualHtml = str_replace('↩', '↩︎', $actualHtml);
|
||||
}
|
||||
|
||||
$this->assertEquals($html, $actualHtml);
|
||||
// asserting a few things instead of comparing full final HTML
|
||||
// because a few minor things have changed over versions of Michelf
|
||||
// With assertContains(), tests will pass across all versions
|
||||
$this->assertContains('<p>That\'s some text with a footnote.<sup id="fnref:1"><a href="#fn:1"', $actualHtml);
|
||||
$this->assertContains('<div class="footnotes"', $actualHtml);
|
||||
$this->assertContains('<li id="fn:1"', $actualHtml);
|
||||
$this->assertContains('<p>And that\'s the footnote. <a href="#fnref:1" class="footnote-backref"', $actualHtml);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,10 +24,5 @@ class ParserManagerTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$actual = $parserManager->transform('*hi*', 'light');
|
||||
$this->assertEquals("<p><em>hi</em></p>\n", $actual, 'Specific parsers are registered');
|
||||
|
||||
/** @var MarkdownHelper $markdownHelper */
|
||||
$markdownHelper = $container->get('templating.helper.markdown');
|
||||
$actual = $markdownHelper->transform('*yo*');
|
||||
$this->assertEquals("<p><em>yo</em></p>\n", $actual, 'The templating helper also works');
|
||||
}
|
||||
}
|
||||
|
|
3
Tests/fixtures/app/TestKernel.php
vendored
3
Tests/fixtures/app/TestKernel.php
vendored
|
@ -5,6 +5,7 @@ namespace Knp\Bundle\MarkdownBundle\Tests\fixtures\app;
|
|||
use Knp\Bundle\MarkdownBundle\KnpMarkdownBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
@ -27,7 +28,7 @@ class TestKernel extends Kernel
|
|||
));
|
||||
|
||||
// add a public alias so we can fetch for testing
|
||||
$c->setAlias('markdown.parser.parser_manager.public', 'markdown.parser.parser_manager');
|
||||
$c->setAlias('markdown.parser.parser_manager.public', new Alias('markdown.parser.parser_manager', true));
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue