Refactor PHPUnit bootstrap

This allows Parsedown extensions (like Parsedown Extra) to reuse existing Parsedown tests. See erusev/parsedown-extra#96 for details.
This commit is contained in:
Daniel Rudolf 2016-09-05 21:10:23 +02:00
parent 228d5f4754
commit 33a23fbfb2
No known key found for this signature in database
GPG Key ID: A061F02CD8DE4538
3 changed files with 18 additions and 7 deletions

View File

@ -13,8 +13,6 @@ class CommonMarkTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
require_once(__DIR__ . '/TestParsedown.php');
$this->parsedown = new TestParsedown();
$this->parsedown->setUrlsLinked(false);
}

View File

@ -27,7 +27,7 @@ class ParsedownTest extends PHPUnit_Framework_TestCase
*/
protected function initParsedown()
{
$Parsedown = new Parsedown();
$Parsedown = new TestParsedown();
return $Parsedown;
}
@ -132,15 +132,14 @@ color: red;
<p>comment</p>
<p>&lt;!-- html comment --&gt;</p>
EXPECTED_HTML;
$parsedownWithNoMarkup = new Parsedown();
$parsedownWithNoMarkup = new TestParsedown();
$parsedownWithNoMarkup->setMarkupEscaped(true);
$this->assertEquals($expectedHtml, $parsedownWithNoMarkup->text($markdownWithHtml));
}
public function testLateStaticBinding()
{
include 'test/TestParsedown.php';
$parsedown = Parsedown::instance();
$this->assertInstanceOf('Parsedown', $parsedown);

View File

@ -1,3 +1,17 @@
<?php
include 'Parsedown.php';
// prepare composer autoloader
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
// composer root package
require_once(__DIR__ . '/../vendor/autoload.php');
} elseif (is_file(__DIR__ . '/../../../../vendor/autoload.php')) {
// composer dependency package
require_once(__DIR__ . '/../../../../vendor/autoload.php');
} else {
die("Cannot find `vendor/autoload.php`. Run `composer install`.");
}
// load TestParsedown class
if (!class_exists('TestParsedown', false) && is_file('test/TestParsedown.php')) {
require_once('test/TestParsedown.php');
}