1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00
parsedown/tests/Test.php

46 lines
947 B
PHP
Raw Normal View History

2013-07-22 00:14:30 +04:00
<?php
include 'Parsedown.php';
class Test extends PHPUnit_Framework_TestCase
{
const provider_dir = 'data/';
2013-07-22 01:19:11 +04:00
/**
* @dataProvider provider
*/
function test_($markdown, $expected_markup)
{
$actual_markup = Parsedown::instance()->parse($markdown);
$this->assertEquals($expected_markup, $actual_markup);
}
2013-07-22 00:14:30 +04:00
2013-07-22 01:19:11 +04:00
function provider()
{
2013-07-22 00:14:30 +04:00
$provider = array();
2013-07-22 01:19:11 +04:00
$DirectoryIterator = new DirectoryIterator(__DIR__ . '/' . self::provider_dir);
2013-07-22 00:14:30 +04:00
foreach ($DirectoryIterator as $Item)
{
if ($Item->isFile() and $Item->getExtension() === 'md')
{
$basename = $Item->getBasename('.md');
2013-07-22 01:19:11 +04:00
$markdown = file_get_contents(__DIR__ . '/' . self::provider_dir . $basename . '.md');
2013-07-22 00:14:30 +04:00
2013-07-22 01:19:11 +04:00
if (!$markdown)
2013-07-22 00:14:30 +04:00
continue;
2013-07-22 01:19:11 +04:00
$expected_markup = file_get_contents(__DIR__ . '/' . self::provider_dir . $basename . '.html');
2013-07-22 00:14:30 +04:00
2013-07-22 01:19:11 +04:00
$provider [] = array($markdown, $expected_markup);
2013-07-22 00:14:30 +04:00
}
}
return $provider;
2013-07-22 01:19:11 +04:00
}
2013-07-22 00:14:30 +04:00
}