* code blocks * paragraphs * horizontal rules * references * tablesfeature/tests
parent
559574b492
commit
3fb2aa6a2d
4 changed files with 168 additions and 0 deletions
@ -0,0 +1,46 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
use PHPUnit\Framework\TestCase; |
||||
|
||||
final class CodeBlocksTest extends TestCase { |
||||
public function testCodeblocksParseCorrectly() : void { |
||||
$source = " |
||||
``` |
||||
this is a code block |
||||
``` |
||||
"; |
||||
$target = " |
||||
<pre> |
||||
<code> |
||||
this is a code block |
||||
</code> |
||||
</pre> |
||||
"; |
||||
|
||||
[$source, $result] = createTest($source, $target); |
||||
$this->assertEquals($source, $result); |
||||
} |
||||
|
||||
public function testLanguageAnnotationParsesCorrectly() : void { |
||||
$source = " |
||||
```php |
||||
public function testLanguageAnnotationParsesCorrectly() : bool { |
||||
return true; |
||||
} |
||||
|
||||
``` |
||||
"; |
||||
$target = " |
||||
<pre data-lang=\"php\"> |
||||
<code> |
||||
public function testLanguageAnnotationParsesCorrectly() : bool { |
||||
return true; |
||||
} |
||||
</code> |
||||
</pre> |
||||
"; |
||||
|
||||
[$source, $result] = createTest($source, $target); |
||||
$this->assertEquals($source, $result); |
||||
} |
||||
} |
@ -0,0 +1,47 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
use PHPUnit\Framework\TestCase; |
||||
|
||||
final class GenericBlocksTest extends TestCase { |
||||
public function testParagraphParsesCorrectly() : void { |
||||
$source = " |
||||
this is a paragraph |
||||
"; |
||||
$target = " |
||||
<p> |
||||
this is a paragraph |
||||
</p> |
||||
"; |
||||
|
||||
[$source, $result] = createTest($source, $target); |
||||
$this->assertEquals($source, $result); |
||||
} |
||||
|
||||
public function testBlockquotesParseCorrectly() : void { |
||||
$source = " |
||||
> this is |
||||
> |
||||
> a blockquote |
||||
|
||||
"; |
||||
$target = " |
||||
<blockquote> |
||||
this is <br><br> |
||||
a blockquote<br> |
||||
</blockquote> |
||||
"; |
||||
|
||||
[$source, $result] = createTest($source, $target); |
||||
$this->assertEquals($source, $result); |
||||
} |
||||
|
||||
public function testHorizontalRuleParsesCorrectly() : void { |
||||
$source = " |
||||
--- |
||||
"; |
||||
$target = "<hr>"; |
||||
|
||||
[$source, $result] = createTest($source, $target); |
||||
$this->assertEquals($source, $result); |
||||
} |
||||
} |
@ -0,0 +1,38 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
use PHPUnit\Framework\TestCase; |
||||
|
||||
final class ReferencesTest extends TestCase { |
||||
public function testSimpleReferencesAreResolvedCorrectly() : void { |
||||
$source = " |
||||
this text uses [a simple reference][1] |
||||
|
||||
[1]: https://massivedynamic.eu |
||||
"; |
||||
$target = " |
||||
<p> |
||||
this text uses <a href=\"https://massivedynamic.eu\">a simple reference</a> |
||||
</p> |
||||
"; |
||||
|
||||
[$source, $result] = createTest($source, $target); |
||||
$this->assertEquals($source, $result); |
||||
} |
||||
|
||||
public function testNamedReferencesAreResolvedCorrectly() : void { |
||||
$source = " |
||||
this text uses [a simple reference][REF] and does it [twice][REF] |
||||
|
||||
[REF]: https://massivedynamic.eu |
||||
"; |
||||
$target = " |
||||
<p> |
||||
this text uses <a href=\"https://massivedynamic.eu\">a simple reference</a> |
||||
and does it <a href=\"https://massivedynamic.eu\">twice</a> |
||||
</p> |
||||
"; |
||||
|
||||
[$source, $result] = createTest($source, $target); |
||||
$this->assertEquals($source, $result); |
||||
} |
||||
} |
@ -0,0 +1,37 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
use PHPUnit\Framework\TestCase; |
||||
|
||||
final class TablesTest extends TestCase { |
||||
public function testTableParsesCorrectly() : void { |
||||
$source = " |
||||
| Product | Amount | Price | |
||||
|:--------|:------:|-------:| |
||||
| Part A | 5 | 20,00€ | |
||||
| Editor | 100 | 39,99€ | |
||||
|
||||
"; |
||||
$target = " |
||||
<table> |
||||
<tr> |
||||
<th style=\"text-align: left\">Product</th> |
||||
<th style=\"text-align: center\">Amount</th> |
||||
<th style=\"text-align: right\">Price</th> |
||||
</tr> |
||||
<tr> |
||||
<td style=\"text-align: left\">Part A</td> |
||||
<td style=\"text-align: center\">5</td> |
||||
<td style=\"text-align: right\">20,00€</td> |
||||
</tr> |
||||
<tr> |
||||
<td style=\"text-align: left\">Editor</td> |
||||
<td style=\"text-align: center\">100</td> |
||||
<td style=\"text-align: right\">39,99€</td> |
||||
</tr> |
||||
</table> |
||||
"; |
||||
|
||||
[$source, $result] = createTest($source, $target); |
||||
$this->assertEquals($source, $result); |
||||
} |
||||
} |
Loading…
Reference in new issue