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
|
<?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\CommonMark;
use League\CommonMark\CommonMarkConverter;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
final class CommonMarkCoreExtensionTest extends TestCase
{
/**
* @param array<string, mixed> $config
*/
#[DataProvider('getTestData')]
public function testConfiguration(string $markdown, array $config, string $expected): void
{
$converter = new CommonMarkConverter($config);
$this->assertSame($expected, (string) $converter->convert($markdown));
}
/**
* @return iterable<array<mixed>>
*/
public static function getTestData(): iterable
{
yield ['*Emphasis*', [], "<p><em>Emphasis</em></p>\n"];
yield ['**Strong**', [], "<p><strong>Strong</strong></p>\n"];
yield ['_Emphasis_', [], "<p><em>Emphasis</em></p>\n"];
yield ['__Strong__', [], "<p><strong>Strong</strong></p>\n"];
yield ['*Emphasis*', ['commonmark' => ['enable_em' => true]], "<p><em>Emphasis</em></p>\n"];
yield ['**Strong**', ['commonmark' => ['enable_strong' => true]], "<p><strong>Strong</strong></p>\n"];
yield ['_Emphasis_', ['commonmark' => ['use_underscore' => true]], "<p><em>Emphasis</em></p>\n"];
yield ['__Strong__', ['commonmark' => ['use_underscore' => true]], "<p><strong>Strong</strong></p>\n"];
yield ['*Emphasis*', ['commonmark' => ['enable_em' => false]], "<p>*Emphasis*</p>\n"];
yield ['**Strong**', ['commonmark' => ['enable_strong' => false]], "<p>**Strong**</p>\n"];
yield ['_Emphasis_', ['commonmark' => ['use_underscore' => false]], "<p>_Emphasis_</p>\n"];
yield ['__Strong__', ['commonmark' => ['use_underscore' => false]], "<p>__Strong__</p>\n"];
}
}
|