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

68 lines
1.5 KiB
PHP
Raw Normal View History

2013-07-22 00:14:30 +04:00
<?php
include 'Parsedown.php';
class Test extends PHPUnit_Framework_TestCase
{
2014-04-17 11:46:07 +04:00
public function __construct($name = null, array $data = array(), $dataName = '')
{
$this->dataDir = dirname(__FILE__).'/data/';
2014-04-17 11:46:07 +04:00
parent::__construct($name, $data, $dataName);
}
private $dataDir;
/**
2014-04-17 14:34:06 +04:00
* @dataProvider data
*/
function test_($filename)
{
$markdown = file_get_contents($this->dataDir . $filename . '.md');
2014-04-17 11:46:07 +04:00
2014-04-17 14:34:06 +04:00
$expectedMarkup = file_get_contents($this->dataDir . $filename . '.html');
2014-02-03 14:23:54 +04:00
2014-04-17 14:34:06 +04:00
$expectedMarkup = str_replace("\r\n", "\n", $expectedMarkup);
$expectedMarkup = str_replace("\r", "\n", $expectedMarkup);
2013-07-22 01:19:11 +04:00
2014-04-17 14:34:06 +04:00
$actualMarkup = Parsedown::instance()->text($markdown);
2014-04-17 11:46:07 +04:00
2014-04-17 14:34:06 +04:00
$this->assertEquals($expectedMarkup, $actualMarkup);
}
2014-04-17 14:34:06 +04:00
function data()
{
$data = array();
2014-04-17 14:34:06 +04:00
$Folder = new DirectoryIterator($this->dataDir);
2014-04-17 14:34:06 +04:00
foreach ($Folder as $File)
{
2014-04-17 11:46:07 +04:00
/** @var $File DirectoryIterator */
2014-04-17 11:46:07 +04:00
if ( ! $File->isFile())
{
continue;
}
2014-04-17 11:46:07 +04:00
$filename = $File->getFilename();
2014-04-17 11:46:07 +04:00
$extension = pathinfo($filename, PATHINFO_EXTENSION);
2014-04-17 11:46:07 +04:00
if ($extension !== 'md')
{
continue;
}
2014-02-03 14:23:54 +04:00
2014-04-17 11:46:07 +04:00
$basename = $File->getBasename('.md');
if (file_exists($this->dataDir . $basename . '.html'))
{
$data []= array($basename);
}
2014-04-17 14:34:06 +04:00
}
2014-04-17 11:46:07 +04:00
2014-04-17 14:34:06 +04:00
return $data;
}
2014-04-17 11:46:07 +04:00
}