1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
<?php
declare(strict_types=1);
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Tests\Functional\Extension\InlinesOnly;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\InlinesOnly\InlinesOnlyExtension;
use League\CommonMark\MarkdownConverter;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
* Tests the extension against sample files
*/
final class InlinesOnlyFunctionalTest extends TestCase
{
private MarkdownConverter $converter;
protected function setUp(): void
{
$environment = new Environment();
$environment->addExtension(new InlinesOnlyExtension());
$this->converter = new MarkdownConverter($environment);
}
/**
* @param string $markdown Markdown to parse
* @param string $html Expected result
*/
#[DataProvider('dataProvider')]
public function testExample(string $markdown, string $html): void
{
$actualResult = $this->converter->convert($markdown);
$failureMessage = 'Unexpected result';
$failureMessage .= "\n=== markdown ===============\n" . $markdown;
$failureMessage .= "\n=== expected ===============\n" . $html;
$failureMessage .= "\n=== got ====================\n" . $actualResult;
$this->assertEquals($html, $actualResult, $failureMessage);
}
/**
* @return array<array<string>>
*/
public static function dataProvider(): array
{
$markdown = \file_get_contents(__DIR__ . '/inlines.md');
$html = \file_get_contents(__DIR__ . '/inlines.html');
return [
[$markdown, $html],
];
}
}
|