mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
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:
parent
228d5f4754
commit
33a23fbfb2
@ -13,8 +13,6 @@ class CommonMarkTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
require_once(__DIR__ . '/TestParsedown.php');
|
|
||||||
|
|
||||||
$this->parsedown = new TestParsedown();
|
$this->parsedown = new TestParsedown();
|
||||||
$this->parsedown->setUrlsLinked(false);
|
$this->parsedown->setUrlsLinked(false);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ class ParsedownTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
protected function initParsedown()
|
protected function initParsedown()
|
||||||
{
|
{
|
||||||
$Parsedown = new Parsedown();
|
$Parsedown = new TestParsedown();
|
||||||
|
|
||||||
return $Parsedown;
|
return $Parsedown;
|
||||||
}
|
}
|
||||||
@ -132,15 +132,14 @@ color: red;
|
|||||||
<p>comment</p>
|
<p>comment</p>
|
||||||
<p><!-- html comment --></p>
|
<p><!-- html comment --></p>
|
||||||
EXPECTED_HTML;
|
EXPECTED_HTML;
|
||||||
$parsedownWithNoMarkup = new Parsedown();
|
|
||||||
|
$parsedownWithNoMarkup = new TestParsedown();
|
||||||
$parsedownWithNoMarkup->setMarkupEscaped(true);
|
$parsedownWithNoMarkup->setMarkupEscaped(true);
|
||||||
$this->assertEquals($expectedHtml, $parsedownWithNoMarkup->text($markdownWithHtml));
|
$this->assertEquals($expectedHtml, $parsedownWithNoMarkup->text($markdownWithHtml));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLateStaticBinding()
|
public function testLateStaticBinding()
|
||||||
{
|
{
|
||||||
include 'test/TestParsedown.php';
|
|
||||||
|
|
||||||
$parsedown = Parsedown::instance();
|
$parsedown = Parsedown::instance();
|
||||||
$this->assertInstanceOf('Parsedown', $parsedown);
|
$this->assertInstanceOf('Parsedown', $parsedown);
|
||||||
|
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
<?php
|
<?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');
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user