diff --git a/tests/BaseMarkdownTest.php b/tests/BaseMarkdownTest.php index 1946221..232d28c 100644 --- a/tests/BaseMarkdownTest.php +++ b/tests/BaseMarkdownTest.php @@ -9,16 +9,16 @@ */ abstract class BaseMarkdownTest extends \PHPUnit_Framework_TestCase { - abstract public function getDataPath(); + abstract public function getDataPaths(); abstract public function createMarkdown(); /** * @dataProvider dataFiles */ - public function testParse($file) + public function testParse($path, $file) { - list($markdown, $html) = $this->getTestData($file); + list($markdown, $html) = $this->getTestData($path, $file); // Different OS line endings should not affect test $html = preg_replace('~\r\n?~', "\n", $html); @@ -26,35 +26,33 @@ public function testParse($file) $this->assertEquals($html, $m->parse($markdown)); } - public function getTestData($file) + public function getTestData($path, $file) { return [ - file_get_contents(__DIR__ . '/' . $this->getDataPath() . '/' . $file . '.md'), - file_get_contents(__DIR__ . '/' . $this->getDataPath() . '/' . $file . '.html'), + file_get_contents($this->getDataPaths()[$path] . '/' . $file . '.md'), + file_get_contents($this->getDataPaths()[$path] . '/' . $file . '.html'), ]; } public function dataFiles() { - $src = __DIR__ . '/' . $this->getDataPath(); - $files = []; - - $handle = opendir($src); - if ($handle === false) { - throw new \Exception('Unable to open directory: ' . $src); - } - while (($file = readdir($handle)) !== false) { - if ($file === '.' || $file === '..') { - continue; + foreach($this->getDataPaths() as $name => $src) { + $handle = opendir($src); + if ($handle === false) { + throw new \Exception('Unable to open directory: ' . $src); } - - if (substr($file, -3, 3) === '.md' && file_exists($src . '/' . substr($file, 0, -3) . '.html')) { - $files[] = [substr($file, 0, -3)]; + while (($file = readdir($handle)) !== false) { + if ($file === '.' || $file === '..') { + continue; + } + + if (substr($file, -3, 3) === '.md' && file_exists($src . '/' . substr($file, 0, -3) . '.html')) { + $files[] = [$name, substr($file, 0, -3)]; + } } + closedir($handle); } - closedir($handle); - return $files; } } diff --git a/tests/GithubMarkdownTest.php b/tests/GithubMarkdownTest.php index e98892d..f67d256 100644 --- a/tests/GithubMarkdownTest.php +++ b/tests/GithubMarkdownTest.php @@ -13,8 +13,11 @@ public function createMarkdown() return new GithubMarkdown(); } - public function getDataPath() + public function getDataPaths() { - return 'github-data'; + return [ + 'markdown-data' => __DIR__ . '/markdown-data', + 'github-data' => __DIR__ . '/github-data', + ]; } } \ No newline at end of file diff --git a/tests/MarkdownTest.php b/tests/MarkdownTest.php index 631099b..5100e77 100644 --- a/tests/MarkdownTest.php +++ b/tests/MarkdownTest.php @@ -14,8 +14,10 @@ public function createMarkdown() return new Markdown(); } - public function getDataPath() + public function getDataPaths() { - return 'markdown-data'; + return [ + 'markdown-data' => __DIR__ . '/markdown-data', + ]; } }