*/ class MarkdownTokenParserTest extends \Twig_Test_NodeTestCase { public function testConstructor() { $body = new \Twig_Node(array(new \Twig_Node_Text("#Title\n\nparagraph\n", 1))); $node = new MarkdownNode($body, 1); $this->assertEquals($body, $node->getNode('body')); } /** * Test that the generated code actually do what we expect * * The contents of this test is the same that we write in the compile method. * This requires manual synchronization, which we should probably not rely on. */ public function testMarkdownPrepareBehavior() { $body = " #Title\n\n paragraph\n\n code"; $bodyPrepared = "#Title\n\nparagraph\n\n code"; ob_start(); echo $body; $content = ob_get_clean(); preg_match("/^\s*/", $content, $matches); $lines = explode("\n", $content); $content = preg_replace('/^' . $matches[0]. '/', "", $lines); $content = join("\n", $content); // Assert prepared content looks right $this->assertEquals($bodyPrepared, $content); // Assert Markdown output $expectedOutput = "
paragraph
\n\ncode\n\n";
$this->assertEquals($expectedOutput, $this->getEngine()->transform($content));
}
/**
* Test that the generated code looks as expected
*
* @dataProvider getTests
*/
public function testCompile($node, $source, $environment = null)
{
parent::testCompile($node, $source, $environment);
}
protected function getEngine()
{
return new MichelfMarkdownEngine();
}
public function getTests()
{
$tests = array();
$body = new \Twig_Node(array(new \Twig_Node_Text("#Title\n\nparagraph\n", 1)));
$node = new MarkdownNode($body, 1);
$tests['simple text'] = array($node, <<