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

Type check tests

This commit is contained in:
Aidan Woods
2019-02-10 22:38:34 +00:00
parent 30613b2430
commit dbe37bcb0e
5 changed files with 116 additions and 51 deletions

View File

@@ -25,7 +25,8 @@ namespace Erusev\Parsedown\Tests;
class CommonMarkTest extends CommonMarkTestStrict
{
/**
* @return array
* @return array<int, array{id: int, section: string, markdown: string, expectedHtml: string}>
* @throws \PHPUnit\Framework\AssertionFailedError
*/
public function data()
{
@@ -68,10 +69,13 @@ class CommonMarkTest extends CommonMarkTestStrict
/**
* @group update
* @dataProvider dataUpdate
* @param $id
* @param $section
* @param $markdown
* @param $expectedHtml
* @param int $id
* @param string $section
* @param string $markdown
* @param string $expectedHtml
* @return void
* @throws \PHPUnit\Framework\AssertionFailedError
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function testUpdateDatabase($id, $section, $markdown, $expectedHtml)
{
@@ -79,19 +83,25 @@ class CommonMarkTest extends CommonMarkTestStrict
// you can only get here when the test passes
$dir = static::getDataDir(true);
$basename = $id . '-' . \preg_replace('/[^\w.-]/', '_', $section);
$basename = \strval($id) . '-' . \preg_replace('/[^\w.-]/', '_', $section);
\file_put_contents($dir . $basename . '.md', $markdown);
\file_put_contents($dir . $basename . '.html', $expectedHtml);
}
/**
* @return array
* @return array<int, array{id: int, section: string, markdown: string, expectedHtml: string}>
* @throws \PHPUnit\Framework\AssertionFailedError
*/
public function dataUpdate()
{
return parent::data();
}
/**
* @param bool $mkdir
* @return string
* @throws \PHPUnit\Framework\AssertionFailedError
*/
public static function getDataDir($mkdir = false)
{
$dir = __DIR__ . '/commonmark/';