-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
now PHPUnit runs both test files. previously PHPUnit only run one.
- Loading branch information
Showing
3 changed files
with
64 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/* | ||
* This file is a part of the PHP Markdown library. | ||
* | ||
* (c) Dragonfly Development Inc. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace DflyDev\Markdown; | ||
|
||
abstract class BaseParserTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
protected $configKeyTabWidth = Parser::CONFIG_TAB_WIDTH; | ||
|
||
protected $object; | ||
|
||
/** | ||
* Simple test to ensure that parser can be created and most basic of | ||
* Markdown can be transformed. | ||
*/ | ||
public function testCreate() | ||
{ | ||
$html = $this->object->transform('#Hello World'); | ||
$this->assertEquals("<h1>Hello World</h1>\n", $html, 'Simple H1 works'); | ||
} | ||
|
||
/** | ||
* Test tab width for code blocks | ||
*/ | ||
public function testTabWidth() | ||
{ | ||
$html = $this->object->transform(' Hello World'); | ||
$this->assertEquals("<pre><code>Hello World\n</code></pre>\n", $html, 'Default 4 space tab code block works'); | ||
$this->configureTabWidth($this->object, 6); | ||
$html = $this->object->transform(' Hello World'); | ||
$this->assertEquals("<p>Hello World</p>\n", $html, 'Default 4 space tab code block not triggered when tab width set to 6'); | ||
$html = $this->object->transform(' Hello World'); | ||
$this->assertEquals("<pre><code>Hello World\n</code></pre>\n", $html, 'Setting 6 space tab code block (via method) works'); | ||
} | ||
|
||
public function testTabWidthConfig() | ||
{ | ||
$this->object = new Parser(array($this->configKeyTabWidth => 8)); | ||
$html = $this->object->transform(' Hello World'); | ||
$this->assertEquals("<pre><code>Hello World\n</code></pre>\n", $html, 'Setting 8 space tab code block (via constructor) works'); | ||
} | ||
|
||
/** | ||
* Configure a Markdown parser for a specific tab width | ||
* @param \dflydev\markdown\MarkdownParser $markdownParser | ||
* @param integer $width | ||
*/ | ||
protected function configureTabWidth(Parser $markdownParser, $width) | ||
{ | ||
$markdownParser->configureMarkdownParser($this->configKeyTabWidth, $width); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters