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:
commit
7a4d3c0f18
@ -9,8 +9,14 @@ class Test extends PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider provider
|
* @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);
|
$actual_markup = Parsedown::instance()->parse($markdown);
|
||||||
|
|
||||||
$this->assertEquals($expected_markup, $actual_markup);
|
$this->assertEquals($expected_markup, $actual_markup);
|
||||||
@ -20,9 +26,8 @@ class Test extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$provider = array();
|
$provider = array();
|
||||||
|
|
||||||
$path = dirname(__FILE__).'/';
|
$path = $this->get_data_path();
|
||||||
|
$DirectoryIterator = new DirectoryIterator($path);
|
||||||
$DirectoryIterator = new DirectoryIterator($path . '/' . self::provider_dir);
|
|
||||||
|
|
||||||
foreach ($DirectoryIterator as $Item)
|
foreach ($DirectoryIterator as $Item)
|
||||||
{
|
{
|
||||||
@ -36,20 +41,17 @@ class Test extends PHPUnit_Framework_TestCase
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
$basename = $Item->getBasename('.md');
|
$basename = $Item->getBasename('.md');
|
||||||
|
if (file_exists($path.$basename.'.html')) {
|
||||||
$markdown = file_get_contents($path . '/' . self::provider_dir . $basename . '.md');
|
$provider [] = array($basename);
|
||||||
|
}
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $provider;
|
return $provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_data_path()
|
||||||
|
{
|
||||||
|
return dirname(__FILE__).'/'.self::provider_dir;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user