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

Merge pull request #85 from cebe/simplify-tests

simplify testing and improved output
This commit is contained in:
Emanuil Rusev 2014-02-04 03:46:39 -08:00
commit 7a4d3c0f18

View File

@ -9,8 +9,14 @@ class Test extends PHPUnit_Framework_TestCase
/**
* @dataProvider provider
*/
function test_($markdown, $expected_markup)
function test_($filename)
{
$path = $this->get_data_path();
$markdown = file_get_contents($path . $filename . '.md');
$expected_markup = file_get_contents($path . $filename . '.html');
$expected_markup = str_replace("\r\n", "\n", $expected_markup);
$expected_markup = str_replace("\r", "\n", $expected_markup);
$actual_markup = Parsedown::instance()->parse($markdown);
$this->assertEquals($expected_markup, $actual_markup);
@ -20,9 +26,8 @@ class Test extends PHPUnit_Framework_TestCase
{
$provider = array();
$path = dirname(__FILE__).'/';
$DirectoryIterator = new DirectoryIterator($path . '/' . self::provider_dir);
$path = $this->get_data_path();
$DirectoryIterator = new DirectoryIterator($path);
foreach ($DirectoryIterator as $Item)
{
@ -36,20 +41,17 @@ class Test extends PHPUnit_Framework_TestCase
continue;
$basename = $Item->getBasename('.md');
$markdown = file_get_contents($path . '/' . self::provider_dir . $basename . '.md');
if (!$markdown)
continue;
$expected_markup = file_get_contents($path . '/' . self::provider_dir . $basename . '.html');
$expected_markup = str_replace("\r\n", "\n", $expected_markup);
$expected_markup = str_replace("\r", "\n", $expected_markup);
$provider [] = array($markdown, $expected_markup);
if (file_exists($path.$basename.'.html')) {
$provider [] = array($basename);
}
}
}
return $provider;
}
function get_data_path()
{
return dirname(__FILE__).'/'.self::provider_dir;
}
}