2013-07-22 00:14:30 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include 'Parsedown.php';
|
|
|
|
|
|
|
|
class Test extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
const provider_dir = 'data/';
|
2013-11-19 00:29:15 +04:00
|
|
|
|
2013-07-22 01:19:11 +04:00
|
|
|
/**
|
|
|
|
* @dataProvider provider
|
|
|
|
*/
|
2014-02-03 14:23:54 +04:00
|
|
|
function test_($filename)
|
2013-07-22 01:19:11 +04:00
|
|
|
{
|
2014-02-03 14:23:54 +04:00
|
|
|
$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);
|
|
|
|
|
2013-07-22 01:19:11 +04:00
|
|
|
$actual_markup = Parsedown::instance()->parse($markdown);
|
|
|
|
|
|
|
|
$this->assertEquals($expected_markup, $actual_markup);
|
|
|
|
}
|
2013-11-19 00:29:15 +04:00
|
|
|
|
2013-07-22 01:19:11 +04:00
|
|
|
function provider()
|
|
|
|
{
|
2013-07-22 00:14:30 +04:00
|
|
|
$provider = array();
|
2013-11-19 00:29:15 +04:00
|
|
|
|
2014-02-03 14:23:54 +04:00
|
|
|
$path = $this->get_data_path();
|
|
|
|
$DirectoryIterator = new DirectoryIterator($path);
|
2013-11-19 00:29:15 +04:00
|
|
|
|
2013-07-22 00:14:30 +04:00
|
|
|
foreach ($DirectoryIterator as $Item)
|
|
|
|
{
|
2013-11-19 00:29:15 +04:00
|
|
|
if ($Item->isFile())
|
2013-07-22 00:14:30 +04:00
|
|
|
{
|
2013-11-19 00:29:15 +04:00
|
|
|
$filename = $Item->getFilename();
|
|
|
|
|
|
|
|
$extension = pathinfo($filename, PATHINFO_EXTENSION);
|
|
|
|
|
|
|
|
if ($extension !== 'md')
|
|
|
|
continue;
|
|
|
|
|
2013-07-22 00:14:30 +04:00
|
|
|
$basename = $Item->getBasename('.md');
|
2014-02-03 14:23:54 +04:00
|
|
|
if (file_exists($path.$basename.'.html')) {
|
|
|
|
$provider [] = array($basename);
|
|
|
|
}
|
2013-07-22 00:14:30 +04:00
|
|
|
}
|
|
|
|
}
|
2013-11-19 00:29:15 +04:00
|
|
|
|
2013-07-22 00:14:30 +04:00
|
|
|
return $provider;
|
2013-07-22 01:19:11 +04:00
|
|
|
}
|
2014-02-03 14:23:54 +04:00
|
|
|
|
|
|
|
function get_data_path()
|
|
|
|
{
|
|
|
|
return dirname(__FILE__).'/'.self::provider_dir;
|
|
|
|
}
|
2013-11-19 00:29:15 +04:00
|
|
|
}
|