From b5dcbac319ca6bf92669594aca21ae8d14315ee5 Mon Sep 17 00:00:00 2001 From: Colin O'Dell Date: Wed, 15 Feb 2023 10:19:32 -0500 Subject: [PATCH 1/7] Allow PHPUnit 10 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 13a937ef12..398df2fdce 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "michelf/php-markdown": "^1.4 || ^2.0", "nyholm/psr7": "^1.5", "phpstan/phpstan": "^1.8.2", - "phpunit/phpunit": "^9.5.21", + "phpunit/phpunit": "^9.5.21 || ^10.0.7", "scrutinizer/ocular": "^1.8.1", "symfony/finder": "^5.3 | ^6.0 || ^7.0", "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 || ^7.0", From e40ee171de420bd0e9b2d7e7db25136bf1b549ce Mon Sep 17 00:00:00 2001 From: Colin O'Dell Date: Wed, 15 Feb 2023 10:19:49 -0500 Subject: [PATCH 2/7] Fix PHPUnit 10 compatibility issues --- ...Test.php => AbstractLocalDataTestCase.php} | 6 +-- ...tSpecTest.php => AbstractSpecTestCase.php} | 15 +------- tests/functional/CMarkRegressionTest.php | 22 ++++------- .../functional/CommonMarkJSRegressionTest.php | 22 ++++------- .../Delimiter/DelimiterProcessingTest.php | 2 +- .../Extension/Attributes/LocalDataTest.php | 8 ++-- .../Extension/Autolink/AutolinkXmlTest.php | 8 ++-- .../Autolink/EmailAutolinkParserTest.php | 2 +- .../Autolink/UrlAutolinkParserTest.php | 2 +- .../CommonMarkCoreExtensionTest.php | 2 +- .../CommonMark/CommonMarkXmlTest.php | 8 ++-- .../DefaultAttributesExtensionTest.php | 2 +- .../DescriptionListSpecTest.php | 9 +++-- .../Bridge/OscaroteroEmbedAdapterTest.php | 8 ++-- .../Extension/Embed/EmbedExtensionTest.php | 8 ++-- .../ExternalLinkExtensionTest.php | 2 +- .../Footnote/FootnoteExtensionGFMTest.php | 8 ++-- .../FootnoteExtensionMarkdownTest.php | 8 ++-- .../Footnote/FootnoteExtensionTest.php | 4 +- .../Footnote/FootnoteExtensionXmlTest.php | 8 ++-- .../Extension/Footnote/FootnoteSpecTest.php | 9 +++-- .../FrontMatterExtensionTest.php | 2 +- .../GithubFlavoredMarkdownExtensionTest.php | 14 +++---- .../HeadingPermalinkExtensionTest.php | 4 +- .../InlinesOnly/InlinesOnlyFunctionalTest.php | 2 +- .../SmartPunct/SmartPunctFunctionalTest.php | 9 +++-- .../SmartPunct/SmartPunctXmlTest.php | 8 ++-- .../StrikethroughExtensionTest.php | 2 +- .../Strikethrough/StrikethroughXmlTest.php | 8 ++-- .../Extension/Table/TableMarkdownTest.php | 8 ++-- .../Extension/Table/TableXmlTest.php | 8 ++-- .../TableOfContentsExtensionTest.php | 8 ++-- .../TableOfContentsXmlTest.php | 8 ++-- .../Extension/TaskList/TaskListXmlTest.php | 8 ++-- tests/functional/LocalDataTest.php | 6 +-- tests/functional/SpecTest.php | 8 ++-- .../DelimiterProcessorCollectionTest.php | 2 +- .../Attributes/Util/AttributesHelperTest.php | 4 +- .../Parser/Inline/BacktickParserTest.php | 2 +- .../Renderer/Block/HeadingRendererTest.php | 2 +- .../Renderer/Block/ListBlockRendererTest.php | 2 +- .../DisallowedRawHtmlRendererTest.php | 4 +- .../ExternalLinkProcessorTest.php | 4 +- .../Data/SymfonyYamlFrontMatterParserTest.php | 4 +- .../ReplaceUnpairedQuotesListenerTest.php | 2 +- tests/unit/Node/QueryTest.php | 38 ++++++++++++------- tests/unit/Normalizer/SlugNormalizerTest.php | 4 +- tests/unit/Normalizer/TextNormalizerTest.php | 2 +- tests/unit/Parser/CursorTest.php | 26 ++++++------- .../Parser/Inline/InlineParserMatchTest.php | 2 +- tests/unit/Reference/ReferenceMapTest.php | 2 +- tests/unit/Util/Html5EntityDecoderTest.php | 2 +- tests/unit/Util/LinkParserHelperTest.php | 4 +- tests/unit/Util/RegexHelperTest.php | 8 ++-- tests/unit/Util/UrlEncoderTest.php | 2 +- tests/unit/Util/XmlTest.php | 2 +- 56 files changed, 188 insertions(+), 196 deletions(-) rename tests/functional/{AbstractLocalDataTest.php => AbstractLocalDataTestCase.php} (90%) rename tests/functional/{AbstractSpecTest.php => AbstractSpecTestCase.php} (80%) diff --git a/tests/functional/AbstractLocalDataTest.php b/tests/functional/AbstractLocalDataTestCase.php similarity index 90% rename from tests/functional/AbstractLocalDataTest.php rename to tests/functional/AbstractLocalDataTestCase.php index 182ad2b0bd..2b33d126df 100644 --- a/tests/functional/AbstractLocalDataTest.php +++ b/tests/functional/AbstractLocalDataTestCase.php @@ -26,7 +26,7 @@ * This is particularly useful for testing minor variations allowed by the spec * or small regressions not tested by the spec. */ -abstract class AbstractLocalDataTest extends TestCase +abstract class AbstractLocalDataTestCase extends TestCase { /** * @param array $config @@ -36,7 +36,7 @@ abstract protected function createConverter(array $config = []): ConverterInterf /** * @return iterable, string}> */ - abstract public function dataProvider(): iterable; + abstract public static function dataProvider(): iterable; /** * @dataProvider dataProvider @@ -61,7 +61,7 @@ public function testWithLocalData(string $markdown, string $html, array $config, /** * @return iterable, string}> */ - protected function loadTests(string $dir, string $pattern = '*', string $inputFormat = '.md', string $outputFormat = '.html'): iterable + final protected static function loadTests(string $dir, string $pattern = '*', string $inputFormat = '.md', string $outputFormat = '.html'): iterable { $finder = new Finder(); $finder->files() diff --git a/tests/functional/AbstractSpecTest.php b/tests/functional/AbstractSpecTestCase.php similarity index 80% rename from tests/functional/AbstractSpecTest.php rename to tests/functional/AbstractSpecTestCase.php index 48b0d436cb..284e396cc4 100644 --- a/tests/functional/AbstractSpecTest.php +++ b/tests/functional/AbstractSpecTestCase.php @@ -18,10 +18,9 @@ use League\CommonMark\CommonMarkConverter; use League\CommonMark\MarkdownConverter; -use League\CommonMark\Util\SpecReader; use PHPUnit\Framework\TestCase; -abstract class AbstractSpecTest extends TestCase +abstract class AbstractSpecTestCase extends TestCase { protected MarkdownConverter $converter; @@ -48,20 +47,10 @@ public function testSpecExample(string $markdown, string $html): void $this->assertEquals($html, $actualResult, $failureMessage); } - public function dataProvider(): \Generator - { - yield from $this->loadSpecExamples(); - } - - protected function loadSpecExamples(): \Generator - { - yield from SpecReader::readFile($this->getFileName()); - } + abstract public static function dataProvider(): \Generator; private function showSpaces(string $str): string { return \strtr($str, ["\t" => '→', ' ' => '␣']); } - - abstract protected function getFileName(): string; } diff --git a/tests/functional/CMarkRegressionTest.php b/tests/functional/CMarkRegressionTest.php index 43e557cce1..d8f3ffb2f2 100644 --- a/tests/functional/CMarkRegressionTest.php +++ b/tests/functional/CMarkRegressionTest.php @@ -16,25 +16,19 @@ namespace League\CommonMark\Tests\Functional; +use League\CommonMark\Util\SpecReader; + /** * Tests the parser against the CommonMark spec */ -final class CMarkRegressionTest extends AbstractSpecTest +final class CMarkRegressionTest extends AbstractSpecTestCase { - protected function getFileName(): string - { - return __DIR__ . '/../../vendor/commonmark/cmark/test/regression.txt'; - } - - /** - * @deprecated - * - * We can't currently render spec example 13 exactly how the upstream library does. We'll likely need to overhaul - * our rendering approach in order to fix that, so we'll use this temporary workaround for now. - */ - public function dataProvider(): \Generator + public static function dataProvider(): \Generator { - foreach (parent::dataProvider() as $example) { + $tests = SpecReader::readFile(__DIR__ . '/../../vendor/commonmark/cmark/test/regression.txt'); + foreach ($tests as $example) { + // We can't currently render spec example 13 exactly how the upstream library does. We'll likely need to overhaul + // our rendering approach in order to fix that, so we'll use this temporary workaround for now. if ($example['number'] === 13) { yield \str_replace('', "\n", $example); } else { diff --git a/tests/functional/CommonMarkJSRegressionTest.php b/tests/functional/CommonMarkJSRegressionTest.php index 63c165352a..bc8e3e93a6 100644 --- a/tests/functional/CommonMarkJSRegressionTest.php +++ b/tests/functional/CommonMarkJSRegressionTest.php @@ -16,25 +16,19 @@ namespace League\CommonMark\Tests\Functional; +use League\CommonMark\Util\SpecReader; + /** * Tests the parser against the CommonMark spec */ -final class CommonMarkJSRegressionTest extends AbstractSpecTest +final class CommonMarkJSRegressionTest extends AbstractSpecTestCase { - protected function getFileName(): string - { - return __DIR__ . '/../../vendor/commonmark/commonmark.js/test/regression.txt'; - } - - /** - * @deprecated - * - * We can't currently render spec example 18 exactly how the upstream library does. We'll likely need to overhaul - * our rendering approach in order to fix that, so we'll use this temporary workaround for now. - */ - public function dataProvider(): \Generator + public static function dataProvider(): \Generator { - foreach (parent::dataProvider() as $example) { + $tests = SpecReader::readFile(__DIR__ . '/../../vendor/commonmark/commonmark.js/test/regression.txt'); + foreach ($tests as $example) { + // We can't currently render spec example 18 exactly how the upstream library does. We'll likely need to overhaul + // our rendering approach in order to fix that, so we'll use this temporary workaround for now. if ($example['number'] === 18) { yield \str_replace('', "\n", $example); } else { diff --git a/tests/functional/Delimiter/DelimiterProcessingTest.php b/tests/functional/Delimiter/DelimiterProcessingTest.php index f7ed1373c9..87a7b7a83c 100644 --- a/tests/functional/Delimiter/DelimiterProcessingTest.php +++ b/tests/functional/Delimiter/DelimiterProcessingTest.php @@ -55,7 +55,7 @@ public function testAsymmetricDelimiterProcessing(string $input, string $expecte /** * @return iterable> */ - public function asymmetricDelimiterDataProvider(): iterable + public static function asymmetricDelimiterDataProvider(): iterable { yield ['{foo} bar', "

FOO bar

\n"]; yield ['f{oo ba}r', "

fOO BAr

\n"]; diff --git a/tests/functional/Extension/Attributes/LocalDataTest.php b/tests/functional/Extension/Attributes/LocalDataTest.php index e9d94bd8a9..03aa5c9693 100644 --- a/tests/functional/Extension/Attributes/LocalDataTest.php +++ b/tests/functional/Extension/Attributes/LocalDataTest.php @@ -20,12 +20,12 @@ use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\GithubFlavoredMarkdownExtension; use League\CommonMark\MarkdownConverter; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; /** * @internal */ -final class LocalDataTest extends AbstractLocalDataTest +final class LocalDataTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -43,8 +43,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/data'); + yield from self::loadTests(__DIR__ . '/data'); } } diff --git a/tests/functional/Extension/Autolink/AutolinkXmlTest.php b/tests/functional/Extension/Autolink/AutolinkXmlTest.php index 8a07a08cba..9f6e68d7d4 100644 --- a/tests/functional/Extension/Autolink/AutolinkXmlTest.php +++ b/tests/functional/Extension/Autolink/AutolinkXmlTest.php @@ -17,10 +17,10 @@ use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\Autolink\AutolinkExtension; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; use League\CommonMark\Xml\MarkdownToXmlConverter; -final class AutolinkXmlTest extends AbstractLocalDataTest +final class AutolinkXmlTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -37,8 +37,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); + yield from self::loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); } } diff --git a/tests/functional/Extension/Autolink/EmailAutolinkParserTest.php b/tests/functional/Extension/Autolink/EmailAutolinkParserTest.php index e89c4e5797..82a44aa846 100644 --- a/tests/functional/Extension/Autolink/EmailAutolinkParserTest.php +++ b/tests/functional/Extension/Autolink/EmailAutolinkParserTest.php @@ -38,7 +38,7 @@ public function testEmailAutolinks(string $input, string $expected): void /** * @return iterable> */ - public function dataProviderForEmailAutolinks(): iterable + public static function dataProviderForEmailAutolinks(): iterable { yield ['You can try emailing foo@example.com but that inbox doesn\'t actually exist.', '

You can try emailing foo@example.com but that inbox doesn\'t actually exist.

']; yield ['> This processor can even handle email addresses like foo@example.com inside of blockquotes!', "
\n

This processor can even handle email addresses like foo@example.com inside of blockquotes!

\n
"]; diff --git a/tests/functional/Extension/Autolink/UrlAutolinkParserTest.php b/tests/functional/Extension/Autolink/UrlAutolinkParserTest.php index 0c280f6154..0057b68bfd 100644 --- a/tests/functional/Extension/Autolink/UrlAutolinkParserTest.php +++ b/tests/functional/Extension/Autolink/UrlAutolinkParserTest.php @@ -39,7 +39,7 @@ public function testUrlAutolinks(string $input, string $expected): void /** * @return iterable> */ - public function dataProviderForAutolinkTests(): iterable + public static function dataProviderForAutolinkTests(): iterable { // Basic examples yield ['You can search on http://google.com for stuff.', '

You can search on http://google.com for stuff.

']; diff --git a/tests/functional/Extension/CommonMark/CommonMarkCoreExtensionTest.php b/tests/functional/Extension/CommonMark/CommonMarkCoreExtensionTest.php index 57129c1b4a..172573f9f3 100644 --- a/tests/functional/Extension/CommonMark/CommonMarkCoreExtensionTest.php +++ b/tests/functional/Extension/CommonMark/CommonMarkCoreExtensionTest.php @@ -33,7 +33,7 @@ public function testConfiguration(string $markdown, array $config, string $expec /** * @return iterable> */ - public function getTestData(): iterable + public static function getTestData(): iterable { yield ['*Emphasis*', [], "

Emphasis

\n"]; yield ['**Strong**', [], "

Strong

\n"]; diff --git a/tests/functional/Extension/CommonMark/CommonMarkXmlTest.php b/tests/functional/Extension/CommonMark/CommonMarkXmlTest.php index f603a5f4d5..73137e5441 100644 --- a/tests/functional/Extension/CommonMark/CommonMarkXmlTest.php +++ b/tests/functional/Extension/CommonMark/CommonMarkXmlTest.php @@ -16,10 +16,10 @@ use League\CommonMark\ConverterInterface; use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; use League\CommonMark\Xml\MarkdownToXmlConverter; -final class CommonMarkXmlTest extends AbstractLocalDataTest +final class CommonMarkXmlTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -35,8 +35,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); + yield from self::loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); } } diff --git a/tests/functional/Extension/DefaultAttributes/DefaultAttributesExtensionTest.php b/tests/functional/Extension/DefaultAttributes/DefaultAttributesExtensionTest.php index 5d23b30277..237fb1ac26 100644 --- a/tests/functional/Extension/DefaultAttributes/DefaultAttributesExtensionTest.php +++ b/tests/functional/Extension/DefaultAttributes/DefaultAttributesExtensionTest.php @@ -46,7 +46,7 @@ public function testExample(string $markdown, array $config, string $expectedHtm /** * @return iterable */ - public function provideTestCases(): iterable + public static function provideTestCases(): iterable { $markdown = <<converter = new MarkdownConverter($environment); } - protected function getFileName(): string + public static function dataProvider(): \Generator { - return __DIR__ . '/spec.txt'; + yield from SpecReader::readFile(__DIR__ . '/spec.txt'); } } diff --git a/tests/functional/Extension/Embed/Bridge/OscaroteroEmbedAdapterTest.php b/tests/functional/Extension/Embed/Bridge/OscaroteroEmbedAdapterTest.php index d29b5f1d58..24c504f455 100644 --- a/tests/functional/Extension/Embed/Bridge/OscaroteroEmbedAdapterTest.php +++ b/tests/functional/Extension/Embed/Bridge/OscaroteroEmbedAdapterTest.php @@ -21,9 +21,9 @@ use League\CommonMark\Extension\Embed\Bridge\OscaroteroEmbedAdapter; use League\CommonMark\Extension\Embed\EmbedExtension; use League\CommonMark\MarkdownConverter; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; -final class OscaroteroEmbedAdapterTest extends AbstractLocalDataTest +final class OscaroteroEmbedAdapterTest extends AbstractLocalDataTestCase { /** * {@inheritDoc} @@ -42,8 +42,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/data'); + yield from self::loadTests(__DIR__ . '/data'); } } diff --git a/tests/functional/Extension/Embed/EmbedExtensionTest.php b/tests/functional/Extension/Embed/EmbedExtensionTest.php index 218d5edfbd..82cbf5d7e5 100644 --- a/tests/functional/Extension/Embed/EmbedExtensionTest.php +++ b/tests/functional/Extension/Embed/EmbedExtensionTest.php @@ -19,10 +19,10 @@ use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\Embed\EmbedExtension; use League\CommonMark\MarkdownConverter; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; use League\CommonMark\Tests\Unit\Extension\Embed\FakeAdapter; -final class EmbedExtensionTest extends AbstractLocalDataTest +final class EmbedExtensionTest extends AbstractLocalDataTestCase { /** * {@inheritDoc} @@ -48,8 +48,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/data'); + yield from self::loadTests(__DIR__ . '/data'); } } diff --git a/tests/functional/Extension/ExternalLink/ExternalLinkExtensionTest.php b/tests/functional/Extension/ExternalLink/ExternalLinkExtensionTest.php index 1a103f3e2d..1df16d7133 100644 --- a/tests/functional/Extension/ExternalLink/ExternalLinkExtensionTest.php +++ b/tests/functional/Extension/ExternalLink/ExternalLinkExtensionTest.php @@ -42,7 +42,7 @@ public function testExtensionWithAutolinks(EnvironmentInterface $environment): v /** * @return iterable */ - public function provideEnvironmentForTestingExtensionWithAutolinks(): iterable + public static function provideEnvironmentForTestingExtensionWithAutolinks(): iterable { $environment1 = new Environment([ 'external_link' => [ diff --git a/tests/functional/Extension/Footnote/FootnoteExtensionGFMTest.php b/tests/functional/Extension/Footnote/FootnoteExtensionGFMTest.php index 4257bfb473..3c1a845087 100644 --- a/tests/functional/Extension/Footnote/FootnoteExtensionGFMTest.php +++ b/tests/functional/Extension/Footnote/FootnoteExtensionGFMTest.php @@ -20,12 +20,12 @@ use League\CommonMark\Extension\Footnote\FootnoteExtension; use League\CommonMark\Extension\GithubFlavoredMarkdownExtension; use League\CommonMark\MarkdownConverter; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; /** * Test with other extensions */ -final class FootnoteExtensionGFMTest extends AbstractLocalDataTest +final class FootnoteExtensionGFMTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -43,8 +43,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/md'); + yield from self::loadTests(__DIR__ . '/md'); } } diff --git a/tests/functional/Extension/Footnote/FootnoteExtensionMarkdownTest.php b/tests/functional/Extension/Footnote/FootnoteExtensionMarkdownTest.php index 954bd20bba..2b80842507 100644 --- a/tests/functional/Extension/Footnote/FootnoteExtensionMarkdownTest.php +++ b/tests/functional/Extension/Footnote/FootnoteExtensionMarkdownTest.php @@ -19,12 +19,12 @@ use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\Footnote\FootnoteExtension; use League\CommonMark\MarkdownConverter; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; /** * Test with minimal extensions */ -final class FootnoteExtensionMarkdownTest extends AbstractLocalDataTest +final class FootnoteExtensionMarkdownTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -41,8 +41,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/md'); + yield from self::loadTests(__DIR__ . '/md'); } } diff --git a/tests/functional/Extension/Footnote/FootnoteExtensionTest.php b/tests/functional/Extension/Footnote/FootnoteExtensionTest.php index 8e0c8399e8..38e0c0bf63 100644 --- a/tests/functional/Extension/Footnote/FootnoteExtensionTest.php +++ b/tests/functional/Extension/Footnote/FootnoteExtensionTest.php @@ -42,7 +42,7 @@ public function testFootnote(string $string, string $expected, array $config = [ /** * @return array> */ - public function dataForIntegrationTest(): array + public static function dataForIntegrationTest(): array { return [ [ @@ -85,7 +85,7 @@ public function testFootnotesWithCustomOptions(string $input, string $expected): $this->assertEquals($expected, \trim((string) $converter->convert($input))); } - public function dataProviderForTestFootnotesWithCustomOptions(): \Generator + public static function dataProviderForTestFootnotesWithCustomOptions(): \Generator { yield ["Here[^note1]\n\n[^note1]: There", '

Here1

' . "\n" . '']; yield ["_Here_[^note1]\n\n[^note1]: **There**", '

Here1

' . "\n" . '']; diff --git a/tests/functional/Extension/Footnote/FootnoteExtensionXmlTest.php b/tests/functional/Extension/Footnote/FootnoteExtensionXmlTest.php index bc96e57569..1007af8436 100644 --- a/tests/functional/Extension/Footnote/FootnoteExtensionXmlTest.php +++ b/tests/functional/Extension/Footnote/FootnoteExtensionXmlTest.php @@ -18,10 +18,10 @@ use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\Footnote\FootnoteExtension; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; use League\CommonMark\Xml\MarkdownToXmlConverter; -final class FootnoteExtensionXmlTest extends AbstractLocalDataTest +final class FootnoteExtensionXmlTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -38,8 +38,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); + yield from self::loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); } } diff --git a/tests/functional/Extension/Footnote/FootnoteSpecTest.php b/tests/functional/Extension/Footnote/FootnoteSpecTest.php index c143333881..489beed2de 100644 --- a/tests/functional/Extension/Footnote/FootnoteSpecTest.php +++ b/tests/functional/Extension/Footnote/FootnoteSpecTest.php @@ -17,9 +17,10 @@ use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\Footnote\FootnoteExtension; use League\CommonMark\MarkdownConverter; -use League\CommonMark\Tests\Functional\AbstractSpecTest; +use League\CommonMark\Tests\Functional\AbstractSpecTestCase; +use League\CommonMark\Util\SpecReader; -final class FootnoteSpecTest extends AbstractSpecTest +final class FootnoteSpecTest extends AbstractSpecTestCase { protected function setUp(): void { @@ -30,8 +31,8 @@ protected function setUp(): void $this->converter = new MarkdownConverter($environment); } - protected function getFileName(): string + public static function dataProvider(): \Generator { - return __DIR__ . '/spec.txt'; + yield from SpecReader::readFile(__DIR__ . '/spec.txt'); } } diff --git a/tests/functional/Extension/FrontMatterExtension/FrontMatterExtensionTest.php b/tests/functional/Extension/FrontMatterExtension/FrontMatterExtensionTest.php index 87c34c6b70..ac030bfaf7 100644 --- a/tests/functional/Extension/FrontMatterExtension/FrontMatterExtensionTest.php +++ b/tests/functional/Extension/FrontMatterExtension/FrontMatterExtensionTest.php @@ -24,7 +24,7 @@ final class FrontMatterExtensionTest extends TestCase /** * @return array{array{FrontMatterDataParserInterface, bool}} */ - public function parserProvider(): array + public static function parserProvider(): array { return [ [new SymfonyYamlFrontMatterParser(), true], diff --git a/tests/functional/Extension/GithubFlavoredMarkdownExtensionTest.php b/tests/functional/Extension/GithubFlavoredMarkdownExtensionTest.php index 59cf37455f..cbc1d55965 100644 --- a/tests/functional/Extension/GithubFlavoredMarkdownExtensionTest.php +++ b/tests/functional/Extension/GithubFlavoredMarkdownExtensionTest.php @@ -14,23 +14,21 @@ namespace League\CommonMark\Tests\Functional\Extension; use League\CommonMark\GithubFlavoredMarkdownConverter; -use League\CommonMark\Tests\Functional\AbstractSpecTest; +use League\CommonMark\Tests\Functional\AbstractSpecTestCase; +use League\CommonMark\Util\SpecReader; -final class GithubFlavoredMarkdownExtensionTest extends AbstractSpecTest +final class GithubFlavoredMarkdownExtensionTest extends AbstractSpecTestCase { protected function setUp(): void { $this->converter = new GithubFlavoredMarkdownConverter(); } - protected function getFileName(): string + public static function dataProvider(): \Generator { - return __DIR__ . '/../../../vendor/github/gfm/test/spec.txt'; - } + $tests = SpecReader::readFile(__DIR__ . '/../../../vendor/github/gfm/test/spec.txt'); - public function dataProvider(): \Generator - { - foreach ($this->loadSpecExamples() as $title => $data) { + foreach ($tests as $title => $data) { // In the GFM spec, standard CommonMark tests are tagged 'example' // and we don't want to test those (because we test those against the // official CommonMark spec), but we DO want to test the GFM-specific ones diff --git a/tests/functional/Extension/HeadingPermalink/HeadingPermalinkExtensionTest.php b/tests/functional/Extension/HeadingPermalink/HeadingPermalinkExtensionTest.php index 8bf772073d..86b25caf88 100644 --- a/tests/functional/Extension/HeadingPermalink/HeadingPermalinkExtensionTest.php +++ b/tests/functional/Extension/HeadingPermalink/HeadingPermalinkExtensionTest.php @@ -40,7 +40,7 @@ public function testHeadingPermalinksWithDefaultOptions(string $input, string $e $this->assertEquals($expected, \trim((string) $converter->convert($input))); } - public function dataProviderForTestHeadingPermalinksWithDefaultOptions(): \Generator + public static function dataProviderForTestHeadingPermalinksWithDefaultOptions(): \Generator { yield ['# Hello World!', \sprintf('

Hello World!

', HeadingPermalinkRenderer::DEFAULT_SYMBOL)]; yield ['# Hello *World*', \sprintf('

Hello World

', HeadingPermalinkRenderer::DEFAULT_SYMBOL)]; @@ -74,7 +74,7 @@ public function testHeadingPermalinksWithCustomOptions(string $input, string $ex $this->assertEquals($expected, \trim((string) $converter->convert($input))); } - public function dataProviderForTestHeadingPermalinksWithCustomOptions(): \Generator + public static function dataProviderForTestHeadingPermalinksWithCustomOptions(): \Generator { yield ['# Hello World!', '

Hello World!¶ 🦄️ <3 You

']; yield ['# Hello *World*', '

Hello World¶ 🦄️ <3 You

']; diff --git a/tests/functional/Extension/InlinesOnly/InlinesOnlyFunctionalTest.php b/tests/functional/Extension/InlinesOnly/InlinesOnlyFunctionalTest.php index e3c612e188..3cdd6ebb92 100644 --- a/tests/functional/Extension/InlinesOnly/InlinesOnlyFunctionalTest.php +++ b/tests/functional/Extension/InlinesOnly/InlinesOnlyFunctionalTest.php @@ -53,7 +53,7 @@ public function testExample(string $markdown, string $html): void /** * @return array> */ - public function dataProvider(): array + public static function dataProvider(): array { $markdown = \file_get_contents(__DIR__ . '/inlines.md'); $html = \file_get_contents(__DIR__ . '/inlines.html'); diff --git a/tests/functional/Extension/SmartPunct/SmartPunctFunctionalTest.php b/tests/functional/Extension/SmartPunct/SmartPunctFunctionalTest.php index 15efd5b60f..0f372c6ba9 100644 --- a/tests/functional/Extension/SmartPunct/SmartPunctFunctionalTest.php +++ b/tests/functional/Extension/SmartPunct/SmartPunctFunctionalTest.php @@ -20,12 +20,13 @@ use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\SmartPunct\SmartPunctExtension; use League\CommonMark\MarkdownConverter; -use League\CommonMark\Tests\Functional\AbstractSpecTest; +use League\CommonMark\Tests\Functional\AbstractSpecTestCase; +use League\CommonMark\Util\SpecReader; /** * Tests the parser against the CommonMark spec */ -final class SmartPunctFunctionalTest extends AbstractSpecTest +final class SmartPunctFunctionalTest extends AbstractSpecTestCase { protected function setUp(): void { @@ -36,8 +37,8 @@ protected function setUp(): void $this->converter = new MarkdownConverter($environment); } - protected function getFileName(): string + public static function dataProvider(): \Generator { - return __DIR__ . '/../../../../vendor/commonmark/commonmark.js/test/smart_punct.txt'; + yield from SpecReader::readFile(__DIR__ . '/../../../../vendor/commonmark/commonmark.js/test/smart_punct.txt'); } } diff --git a/tests/functional/Extension/SmartPunct/SmartPunctXmlTest.php b/tests/functional/Extension/SmartPunct/SmartPunctXmlTest.php index a68a8d8426..66a6bded11 100644 --- a/tests/functional/Extension/SmartPunct/SmartPunctXmlTest.php +++ b/tests/functional/Extension/SmartPunct/SmartPunctXmlTest.php @@ -17,10 +17,10 @@ use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\SmartPunct\SmartPunctExtension; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; use League\CommonMark\Xml\MarkdownToXmlConverter; -final class SmartPunctXmlTest extends AbstractLocalDataTest +final class SmartPunctXmlTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -37,8 +37,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); + yield from self::loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); } } diff --git a/tests/functional/Extension/Strikethrough/StrikethroughExtensionTest.php b/tests/functional/Extension/Strikethrough/StrikethroughExtensionTest.php index 5d1b86762a..2c27fad309 100644 --- a/tests/functional/Extension/Strikethrough/StrikethroughExtensionTest.php +++ b/tests/functional/Extension/Strikethrough/StrikethroughExtensionTest.php @@ -44,7 +44,7 @@ public function testStrikethrough(string $string, string $expected): void /** * @return array> */ - public function dataForIntegrationTest(): array + public static function dataForIntegrationTest(): array { return [ ['~~Hi~~ Hello, ~there~ world!', "

Hi Hello, there world!

\n"], diff --git a/tests/functional/Extension/Strikethrough/StrikethroughXmlTest.php b/tests/functional/Extension/Strikethrough/StrikethroughXmlTest.php index 82552751a7..4d3842c0ce 100644 --- a/tests/functional/Extension/Strikethrough/StrikethroughXmlTest.php +++ b/tests/functional/Extension/Strikethrough/StrikethroughXmlTest.php @@ -17,10 +17,10 @@ use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\Strikethrough\StrikethroughExtension; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; use League\CommonMark\Xml\MarkdownToXmlConverter; -final class StrikethroughXmlTest extends AbstractLocalDataTest +final class StrikethroughXmlTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -37,8 +37,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); + yield from self::loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); } } diff --git a/tests/functional/Extension/Table/TableMarkdownTest.php b/tests/functional/Extension/Table/TableMarkdownTest.php index f80ec0b2b6..c38ef0ce8c 100644 --- a/tests/functional/Extension/Table/TableMarkdownTest.php +++ b/tests/functional/Extension/Table/TableMarkdownTest.php @@ -20,12 +20,12 @@ use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\Table\TableExtension; use League\CommonMark\MarkdownConverter; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; /** * @internal */ -final class TableMarkdownTest extends AbstractLocalDataTest +final class TableMarkdownTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -42,8 +42,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/md'); + yield from self::loadTests(__DIR__ . '/md'); } } diff --git a/tests/functional/Extension/Table/TableXmlTest.php b/tests/functional/Extension/Table/TableXmlTest.php index dad3814db4..407f8c3fa9 100644 --- a/tests/functional/Extension/Table/TableXmlTest.php +++ b/tests/functional/Extension/Table/TableXmlTest.php @@ -17,10 +17,10 @@ use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\Table\TableExtension; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; use League\CommonMark\Xml\MarkdownToXmlConverter; -final class TableXmlTest extends AbstractLocalDataTest +final class TableXmlTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -37,8 +37,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); + yield from self::loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); } } diff --git a/tests/functional/Extension/TableOfContents/TableOfContentsExtensionTest.php b/tests/functional/Extension/TableOfContents/TableOfContentsExtensionTest.php index 66ca612853..a1b4865029 100644 --- a/tests/functional/Extension/TableOfContents/TableOfContentsExtensionTest.php +++ b/tests/functional/Extension/TableOfContents/TableOfContentsExtensionTest.php @@ -19,9 +19,9 @@ use League\CommonMark\Extension\HeadingPermalink\HeadingPermalinkExtension; use League\CommonMark\Extension\TableOfContents\TableOfContentsExtension; use League\CommonMark\MarkdownConverter; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; -final class TableOfContentsExtensionTest extends AbstractLocalDataTest +final class TableOfContentsExtensionTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -39,8 +39,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/md'); + yield from self::loadTests(__DIR__ . '/md'); } } diff --git a/tests/functional/Extension/TableOfContents/TableOfContentsXmlTest.php b/tests/functional/Extension/TableOfContents/TableOfContentsXmlTest.php index 1b66d0472c..1486b1167b 100644 --- a/tests/functional/Extension/TableOfContents/TableOfContentsXmlTest.php +++ b/tests/functional/Extension/TableOfContents/TableOfContentsXmlTest.php @@ -18,10 +18,10 @@ use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\HeadingPermalink\HeadingPermalinkExtension; use League\CommonMark\Extension\TableOfContents\TableOfContentsExtension; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; use League\CommonMark\Xml\MarkdownToXmlConverter; -final class TableOfContentsXmlTest extends AbstractLocalDataTest +final class TableOfContentsXmlTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -39,8 +39,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); + yield from self::loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); } } diff --git a/tests/functional/Extension/TaskList/TaskListXmlTest.php b/tests/functional/Extension/TaskList/TaskListXmlTest.php index 63e40998d5..ed9e36bb04 100644 --- a/tests/functional/Extension/TaskList/TaskListXmlTest.php +++ b/tests/functional/Extension/TaskList/TaskListXmlTest.php @@ -17,10 +17,10 @@ use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\TaskList\TaskListExtension; -use League\CommonMark\Tests\Functional\AbstractLocalDataTest; +use League\CommonMark\Tests\Functional\AbstractLocalDataTestCase; use League\CommonMark\Xml\MarkdownToXmlConverter; -final class TaskListXmlTest extends AbstractLocalDataTest +final class TaskListXmlTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -37,8 +37,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); + yield from self::loadTests(__DIR__ . '/xml', '*', '.md', '.xml'); } } diff --git a/tests/functional/LocalDataTest.php b/tests/functional/LocalDataTest.php index 8a10f1f313..8185a7b5a3 100644 --- a/tests/functional/LocalDataTest.php +++ b/tests/functional/LocalDataTest.php @@ -22,7 +22,7 @@ * This is particularly useful for testing minor variations allowed by the spec * or small regressions not tested by the spec. */ -final class LocalDataTest extends AbstractLocalDataTest +final class LocalDataTest extends AbstractLocalDataTestCase { /** * @param array $config @@ -35,8 +35,8 @@ protected function createConverter(array $config = []): ConverterInterface /** * {@inheritDoc} */ - public function dataProvider(): iterable + public static function dataProvider(): iterable { - yield from $this->loadTests(__DIR__ . '/data'); + yield from self::loadTests(__DIR__ . '/data'); } } diff --git a/tests/functional/SpecTest.php b/tests/functional/SpecTest.php index 11f4e1c7af..436adbaed3 100644 --- a/tests/functional/SpecTest.php +++ b/tests/functional/SpecTest.php @@ -16,13 +16,15 @@ namespace League\CommonMark\Tests\Functional; +use League\CommonMark\Util\SpecReader; + /** * Tests the parser against the CommonMark spec */ -final class SpecTest extends AbstractSpecTest +final class SpecTest extends AbstractSpecTestCase { - protected function getFileName(): string + public static function dataProvider(): \Generator { - return __DIR__ . '/../../vendor/commonmark/commonmark.js/test/spec.txt'; + yield from SpecReader::readFile(__DIR__ . '/../../vendor/commonmark/commonmark.js/test/spec.txt'); } } diff --git a/tests/unit/Delimiter/DelimiterProcessorCollectionTest.php b/tests/unit/Delimiter/DelimiterProcessorCollectionTest.php index dcd620665c..ac14b2d2c7 100644 --- a/tests/unit/Delimiter/DelimiterProcessorCollectionTest.php +++ b/tests/unit/Delimiter/DelimiterProcessorCollectionTest.php @@ -41,7 +41,7 @@ public function testAddNewProcessor(): void public function testAddProcessorForCharacterAlreadyRegistered(): void { $this->expectException(InvalidArgumentException::class); - $this->expectErrorMessage('Delim processor for character "*" already exists'); + $this->expectExceptionMessage('Delim processor for character "*" already exists'); $collection = new DelimiterProcessorCollection(); diff --git a/tests/unit/Extension/Attributes/Util/AttributesHelperTest.php b/tests/unit/Extension/Attributes/Util/AttributesHelperTest.php index 17a465348a..c41709bd31 100644 --- a/tests/unit/Extension/Attributes/Util/AttributesHelperTest.php +++ b/tests/unit/Extension/Attributes/Util/AttributesHelperTest.php @@ -38,7 +38,7 @@ public function testParseAttributes(Cursor $input, array $expectedResult, string /** * @return iterable> */ - public function dataForTestParseAttributes(): iterable + public static function dataForTestParseAttributes(): iterable { yield [new Cursor(''), [], '']; yield [new Cursor('{}'), [], '{}']; @@ -116,7 +116,7 @@ public function testMergeAttributes($a1, $a2, array $expected): void /** * @return iterable> */ - public function dataForTestMergeAttributes(): iterable + public static function dataForTestMergeAttributes(): iterable { yield [ [], diff --git a/tests/unit/Extension/CommonMark/Parser/Inline/BacktickParserTest.php b/tests/unit/Extension/CommonMark/Parser/Inline/BacktickParserTest.php index 42c74c34fe..44dbd2c3f2 100644 --- a/tests/unit/Extension/CommonMark/Parser/Inline/BacktickParserTest.php +++ b/tests/unit/Extension/CommonMark/Parser/Inline/BacktickParserTest.php @@ -52,7 +52,7 @@ public function testParse(string $string, string $expectedContents): void /** * @return iterable> */ - public function dataForTestParse(): iterable + public static function dataForTestParse(): iterable { return [ ['This is `just` a test', 'just'], diff --git a/tests/unit/Extension/CommonMark/Renderer/Block/HeadingRendererTest.php b/tests/unit/Extension/CommonMark/Renderer/Block/HeadingRendererTest.php index 7ecf1dbb7a..616800cd5d 100644 --- a/tests/unit/Extension/CommonMark/Renderer/Block/HeadingRendererTest.php +++ b/tests/unit/Extension/CommonMark/Renderer/Block/HeadingRendererTest.php @@ -54,7 +54,7 @@ public function testRender(int $level, string $expectedTag): void /** * @return iterable> */ - public function dataForTestRender(): iterable + public static function dataForTestRender(): iterable { return [ [1, 'h1'], diff --git a/tests/unit/Extension/CommonMark/Renderer/Block/ListBlockRendererTest.php b/tests/unit/Extension/CommonMark/Renderer/Block/ListBlockRendererTest.php index 9e3e9b7df7..b145f8c38d 100644 --- a/tests/unit/Extension/CommonMark/Renderer/Block/ListBlockRendererTest.php +++ b/tests/unit/Extension/CommonMark/Renderer/Block/ListBlockRendererTest.php @@ -57,7 +57,7 @@ public function testRenderOrderedList(?int $listStart = null, $expectedAttribute /** * @return iterable> */ - public function dataForTestOrderedListStartingNumber(): iterable + public static function dataForTestOrderedListStartingNumber(): iterable { return [ [null, null], diff --git a/tests/unit/Extension/DisallowedRawHtml/DisallowedRawHtmlRendererTest.php b/tests/unit/Extension/DisallowedRawHtml/DisallowedRawHtmlRendererTest.php index 968d780abf..c1557fe1b3 100644 --- a/tests/unit/Extension/DisallowedRawHtml/DisallowedRawHtmlRendererTest.php +++ b/tests/unit/Extension/DisallowedRawHtml/DisallowedRawHtmlRendererTest.php @@ -52,7 +52,7 @@ public function testWithDefaultSettings(string $input, string $expectedOutput): /** * @return iterable */ - public function dataProviderForTestWithDefaultSettings(): iterable + public static function dataProviderForTestWithDefaultSettings(): iterable { // Different tag variants yield ['', '<title>']; @@ -98,7 +98,7 @@ public function testWithCustomSettings(string $input, string $expectedOutput): v /** * @return iterable<mixed> */ - public function dataProviderForTestWithCustomSettings(): iterable + public static function dataProviderForTestWithCustomSettings(): iterable { // Tags that I've configured to escape yield ['<strong>', '<strong>']; diff --git a/tests/unit/Extension/ExternalLink/ExternalLinkProcessorTest.php b/tests/unit/Extension/ExternalLink/ExternalLinkProcessorTest.php index 6a752c640b..6a93b14f33 100644 --- a/tests/unit/Extension/ExternalLink/ExternalLinkProcessorTest.php +++ b/tests/unit/Extension/ExternalLink/ExternalLinkProcessorTest.php @@ -82,7 +82,7 @@ public function testHostMatches(string $host, $compareTo, bool $expected): void /** * @return iterable<array<string|bool>> */ - public function dataProviderForTestHostMatches(): iterable + public static function dataProviderForTestHostMatches(): iterable { // String-to-string comparison must match exactly yield ['colinodell.com', 'commonmark.thephpleague.com', false]; @@ -120,7 +120,7 @@ public function testRelOptions(string $nofollow, string $noopener, string $noref /** * @return iterable<string[]> */ - public function dataProviderForTestRelOptions(): iterable + public static function dataProviderForTestRelOptions(): iterable { // phpcs:disable SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace.SpaceAfterComma yield ['', '', '', '<p>My favorite sites are <a href="https://www.colinodell.com">https://www.colinodell.com</a> and <a href="https://commonmark.thephpleague.com">https://commonmark.thephpleague.com</a></p>']; diff --git a/tests/unit/Extension/FrontMatter/Data/SymfonyYamlFrontMatterParserTest.php b/tests/unit/Extension/FrontMatter/Data/SymfonyYamlFrontMatterParserTest.php index 37f9b41c9c..ca901fa9e9 100644 --- a/tests/unit/Extension/FrontMatter/Data/SymfonyYamlFrontMatterParserTest.php +++ b/tests/unit/Extension/FrontMatter/Data/SymfonyYamlFrontMatterParserTest.php @@ -35,7 +35,7 @@ public function testParseWithValidYaml(string $input, $expected): void /** * @return iterable<mixed> */ - public function provideValidYamlExamples(): iterable + public static function provideValidYamlExamples(): iterable { yield ['Hello, World!', 'Hello, World!']; yield ["- 1\n- 2\n- 3", [1, 2, 3]]; @@ -57,7 +57,7 @@ public function testParseWithInvalidYaml(string $input): void /** * @return iterable<string> */ - public function provideInvalidYamlExamples(): iterable + public static function provideInvalidYamlExamples(): iterable { yield ["this:\n is:invalid\n yaml: data"]; diff --git a/tests/unit/Extension/SmartPunct/ReplaceUnpairedQuotesListenerTest.php b/tests/unit/Extension/SmartPunct/ReplaceUnpairedQuotesListenerTest.php index ddc50deb65..c15f722dc2 100644 --- a/tests/unit/Extension/SmartPunct/ReplaceUnpairedQuotesListenerTest.php +++ b/tests/unit/Extension/SmartPunct/ReplaceUnpairedQuotesListenerTest.php @@ -46,7 +46,7 @@ public function testWithConsecutiveMerging(array $paragraphNodes, string $expect /** * @return iterable<mixed> */ - public function provideTestData(): iterable + public static function provideTestData(): iterable { yield [ [ diff --git a/tests/unit/Node/QueryTest.php b/tests/unit/Node/QueryTest.php index c8a509272d..edb6b475b0 100644 --- a/tests/unit/Node/QueryTest.php +++ b/tests/unit/Node/QueryTest.php @@ -57,7 +57,7 @@ public function testFindAll(): void $result = \iterator_to_array($result); - $this->assertCount(6, $result); + $this->assertNodeCount(6, $result); // The order is based on node walking $this->assertSame(2, $result[0]->data->get('number')); @@ -76,7 +76,7 @@ public function testFindAllWithLimit(): void $result = \iterator_to_array($result); - $this->assertCount(3, $result); + $this->assertNodeCount(3, $result); $this->assertSame(2, $result[0]->data->get('number')); $this->assertSame(3, $result[1]->data->get('number')); @@ -90,14 +90,14 @@ public function testFindAllWithMixedConditions(): void // "class is SimpleNode AND has parent" $query = (new Query())->where(Query::type(SimpleNode::class), Query::hasParent()); - $this->assertCount(6, $query->findAll($ast)); + $this->assertNodeCount(6, $query->findAll($ast)); // "class is SimpleNode AND has parent AND number > 2" $query->andWhere(static function (Node $node): bool { return $node->data->get('number') > 2; }); - $this->assertCount(5, $query->findAll($ast)); + $this->assertNodeCount(5, $query->findAll($ast)); // "class is SimpleNode AND has parent AND number > 2 AND number > 3 AND number > 7" $query->andWhere( @@ -109,24 +109,24 @@ static function (Node $node): bool { } ); - $this->assertCount(3, $query->findAll($ast)); + $this->assertNodeCount(3, $query->findAll($ast)); // "has child OR (class is SimpleNode AND has parent AND number > 2 AND number > 3 AND number > 7)" $query->orWhere(Query::hasChild()); - $this->assertCount(5, $query->findAll($ast)); + $this->assertNodeCount(5, $query->findAll($ast)); // "has child OR (class is SimpleNode AND has parent AND number > 2 AND number > 3 AND number > 7) OR has parent OR class is SimpleNode" $query->orWhere(Query::hasParent(), Query::type(SimpleNode::class)); - $this->assertCount(7, $query->findAll($ast)); + $this->assertNodeCount(7, $query->findAll($ast)); // "number > 4 AND (has child OR (class is SimpleNode AND has parent AND number > 2 AND number > 3 AND number > 7) OR has parent OR class is SimpleNode)" $query->andWhere(static function (Node $node): bool { return $node->data->get('number') > 4; }); - $this->assertCount(3, $query->findAll($ast)); + $this->assertNodeCount(3, $query->findAll($ast)); } public function testWhereUsingExpressionInterface(): void @@ -138,7 +138,7 @@ public function __invoke(Node $node): bool } }); - $this->assertCount(3, $query->findAll($this->createAST())); + $this->assertNodeCount(3, $query->findAll($this->createAST())); } public function testWhereClausesUsingExpressionInterface(): void @@ -172,7 +172,7 @@ public function __invoke(Node $node): bool $result = \iterator_to_array($result); - $this->assertCount(3, $result); + $this->assertNodeCount(3, $result); $this->assertSame(6, $result[0]->data->get('number')); $this->assertSame(4, $result[1]->data->get('number')); $this->assertSame(5, $result[2]->data->get('number')); @@ -191,7 +191,7 @@ public function __invoke(Node $node): bool } ); - $this->assertCount(5, $query->findAll($this->createAST())); + $this->assertNodeCount(5, $query->findAll($this->createAST())); } public function testFindAllWhenNothingMatches(): void @@ -202,14 +202,14 @@ public function testFindAllWhenNothingMatches(): void }) ->findAll($this->createAST()); - $this->assertCount(0, $result); + $this->assertNodeCount(0, $result); } public function testFindAllWithNoCriteria(): void { $result = (new Query())->findAll($this->createAST()); - $this->assertCount(7, $result); + $this->assertNodeCount(7, $result); } public function testType(): void @@ -312,4 +312,16 @@ private function createAST(): Node return $parent; } + + /** + * @param iterable<mixed> $astIterator + */ + private function assertNodeCount(int $expectedCount, iterable $astIterator): void + { + if (\is_array($astIterator) || $astIterator instanceof \Countable) { + $this->assertCount($expectedCount, $astIterator); + } else { + $this->assertCount($expectedCount, \iterator_to_array($astIterator)); + } + } } diff --git a/tests/unit/Normalizer/SlugNormalizerTest.php b/tests/unit/Normalizer/SlugNormalizerTest.php index d626f6035d..0a71927e65 100644 --- a/tests/unit/Normalizer/SlugNormalizerTest.php +++ b/tests/unit/Normalizer/SlugNormalizerTest.php @@ -30,7 +30,7 @@ public function testNormalize(string $input, string $expectedOutput): void /** * @return iterable<string[]> */ - public function dataProviderForTestNormalize(): iterable + public static function dataProviderForTestNormalize(): iterable { yield ['', '']; yield ['hello world', 'hello-world']; @@ -81,7 +81,7 @@ public function testNormalizeWithMaxLength(string $input, int $maxLength, string /** * @return iterable<mixed> */ - public function dataProviderForTestNormalizeWithMaxLength(): iterable + public static function dataProviderForTestNormalizeWithMaxLength(): iterable { yield ['Hello World', 8, 'hello-wo']; yield ['Hello World', 999, 'hello-world']; diff --git a/tests/unit/Normalizer/TextNormalizerTest.php b/tests/unit/Normalizer/TextNormalizerTest.php index d9a40ada31..945cf0456c 100644 --- a/tests/unit/Normalizer/TextNormalizerTest.php +++ b/tests/unit/Normalizer/TextNormalizerTest.php @@ -29,7 +29,7 @@ public function testNormalize(string $input, string $expectedOutput): void /** * @return iterable<string[]> */ - public function dataProviderForTestNormalize(): iterable + public static function dataProviderForTestNormalize(): iterable { yield ['', '']; yield ['hello world', 'hello world']; diff --git a/tests/unit/Parser/CursorTest.php b/tests/unit/Parser/CursorTest.php index a227234c9a..4fddbb0344 100644 --- a/tests/unit/Parser/CursorTest.php +++ b/tests/unit/Parser/CursorTest.php @@ -57,7 +57,7 @@ public function testGetNextNonSpaceCharacter(string $string, int $expectedPositi /** * @return iterable<array<mixed>> */ - public function dataForTestingNextNonSpaceMethods(): iterable + public static function dataForTestingNextNonSpaceMethods(): iterable { return [ ['', 0, null], @@ -85,7 +85,7 @@ public function testGetIndent(string $string, int $position, int $expectedValue) /** * @return iterable<array<mixed>> */ - public function dataForGetIndentTest(): iterable + public static function dataForGetIndentTest(): iterable { return [ ['', 0, 0], @@ -136,7 +136,7 @@ public function testGetCurrentCharacter(string $string, ?int $index, string $exp /** * @return iterable<array<mixed>> */ - public function dataForGetCharacterTest(): iterable + public static function dataForGetCharacterTest(): iterable { return [ ['', null, ''], @@ -168,7 +168,7 @@ public function testPeek(string $string, int $position, string $expectedValue): /** * @return iterable<array<mixed>> */ - public function dataForPeekTest(): iterable + public static function dataForPeekTest(): iterable { return [ ['', 0, ''], @@ -193,7 +193,7 @@ public function testIsLineBlank(string $string, bool $expectedValue): void /** * @return iterable<array<mixed>> */ - public function dataForIsLineBlankTest(): iterable + public static function dataForIsLineBlankTest(): iterable { return [ ['', true], @@ -221,7 +221,7 @@ public function testAdvance(string $string, int $numberOfAdvances, int $expected /** * @return iterable<array<mixed>> */ - public function dataForAdvanceTest(): iterable + public static function dataForAdvanceTest(): iterable { return [ ['', 0, 0], @@ -255,7 +255,7 @@ public function testAdvanceBy(string $string, int $advance, int $expectedPositio /** * @return iterable<array<mixed>> */ - public function dataForAdvanceTestBy(): iterable + public static function dataForAdvanceTestBy(): iterable { return [ ['', 0, 0], @@ -318,7 +318,7 @@ public function testAdvanceToNextNonSpace(string $subject, int $startPos, int $e /** * @return iterable<array<mixed>> */ - public function dataForAdvanceToNextNonSpaceTest(): iterable + public static function dataForAdvanceToNextNonSpaceTest(): iterable { return [ ['', 0, 0], @@ -356,7 +356,7 @@ public function testAdvanceToNextNonSpaceOrNewline(string $subject, int $startPo /** * @return iterable<array<mixed>> */ - public function dataForAdvanceToNextNonSpaceOrNewlineTest(): iterable + public static function dataForAdvanceToNextNonSpaceOrNewlineTest(): iterable { return [ ['', 0, 0], @@ -394,7 +394,7 @@ public function testGetRemainder(string $string, int $position, string $expected /** * @return iterable<array<mixed>> */ - public function dataForGetRemainderTest(): iterable + public static function dataForGetRemainderTest(): iterable { return [ [' ', 0, ' '], @@ -426,7 +426,7 @@ public function testIsAtEnd(string $string, $advanceBy, bool $expectedValue): vo /** * @return iterable<array<mixed>> */ - public function dataForIsAtEndTest(): iterable + public static function dataForIsAtEndTest(): iterable { return [ ['', false, true], @@ -456,7 +456,7 @@ public function testMatch(string $string, string $regex, int $initialPosition, i /** * @return iterable<array<mixed>> */ - public function dataForTestMatch(): iterable + public static function dataForTestMatch(): iterable { return [ ['this is a test', '/[aeiou]s/', 0, 4, 'is'], @@ -482,7 +482,7 @@ public function testGetSubstring(string $string, int $start, ?int $length, strin /** * @return iterable<array<mixed>> */ - public function dataForTestGetSubstring(): iterable + public static function dataForTestGetSubstring(): iterable { yield ['Hello', 0, 2, 'He']; yield ['Hello', 1, 3, 'ell']; diff --git a/tests/unit/Parser/Inline/InlineParserMatchTest.php b/tests/unit/Parser/Inline/InlineParserMatchTest.php index 549ffc2801..864cec56fe 100644 --- a/tests/unit/Parser/Inline/InlineParserMatchTest.php +++ b/tests/unit/Parser/Inline/InlineParserMatchTest.php @@ -30,7 +30,7 @@ public function testGetRegex(InlineParserMatch $definition, string $expectedRege /** * @return iterable<array{0: InlineParserMatch, 1: string}> */ - public function provideDataForTesting(): iterable + public static function provideDataForTesting(): iterable { yield [InlineParserMatch::string('.'), '/\./i']; yield [InlineParserMatch::string('...'), '/\.\.\./i']; diff --git a/tests/unit/Reference/ReferenceMapTest.php b/tests/unit/Reference/ReferenceMapTest.php index b2789ca7cd..acee2870f2 100644 --- a/tests/unit/Reference/ReferenceMapTest.php +++ b/tests/unit/Reference/ReferenceMapTest.php @@ -52,7 +52,7 @@ public function testUnicodeCaseFolding(string $label): void /** * @return iterable<array<string>> */ - public function provideLabelsForCaseFoldingTest(): iterable + public static function provideLabelsForCaseFoldingTest(): iterable { yield ['ẞ']; yield ['ß']; diff --git a/tests/unit/Util/Html5EntityDecoderTest.php b/tests/unit/Util/Html5EntityDecoderTest.php index 4c28dd8717..a3435a8a3e 100644 --- a/tests/unit/Util/Html5EntityDecoderTest.php +++ b/tests/unit/Util/Html5EntityDecoderTest.php @@ -30,7 +30,7 @@ public function testAllHtml5EntityReferences(string $entity, string $decoded): v /** * @return iterable<array<mixed>> */ - public function htmlEntityDataProvider(): iterable + public static function htmlEntityDataProvider(): iterable { // Test data from https://html.spec.whatwg.org/multipage/entities.json $data = \json_decode(\file_get_contents(__DIR__ . '/entities.json'), true); diff --git a/tests/unit/Util/LinkParserHelperTest.php b/tests/unit/Util/LinkParserHelperTest.php index 39d826ce11..87db7ac8ff 100644 --- a/tests/unit/Util/LinkParserHelperTest.php +++ b/tests/unit/Util/LinkParserHelperTest.php @@ -31,7 +31,7 @@ public function testParseLinkDestination(string $input, string $expected): void /** * @return iterable<array<string>> */ - public function dataProviderForTestParseLinkDestination(): iterable + public static function dataProviderForTestParseLinkDestination(): iterable { yield ['www.google.com', 'www.google.com']; yield ['<www.google.com>', 'www.google.com']; @@ -51,7 +51,7 @@ public function testParseLinkLabel(string $input, int $expected): void /** * @return iterable<array<mixed>> */ - public function dataProviderForTestParseLinkLabel(): iterable + public static function dataProviderForTestParseLinkLabel(): iterable { yield ['[link](http://example.com)', 6]; yield ['[\\]: test', 0]; diff --git a/tests/unit/Util/RegexHelperTest.php b/tests/unit/Util/RegexHelperTest.php index a9c16e67c7..463e23f1da 100644 --- a/tests/unit/Util/RegexHelperTest.php +++ b/tests/unit/Util/RegexHelperTest.php @@ -296,7 +296,7 @@ public function testMatchAt(string $regex, string $string, ?int $offset, int $ex /** * @return iterable<array<mixed>> */ - public function dataForTestMatchAt(): iterable + public static function dataForTestMatchAt(): iterable { return [ ['/ /', 'foo bar', null, 3], @@ -329,7 +329,7 @@ public function testValidHtmlBlockOpenRegex(int $type): void /** * @return iterable<int> */ - public function blockTypesWithValidOpenerRegexes(): iterable + public static function blockTypesWithValidOpenerRegexes(): iterable { yield [HtmlBlock::TYPE_1_CODE_CONTAINER]; yield [HtmlBlock::TYPE_2_COMMENT]; @@ -358,7 +358,7 @@ public function testValidHtmlBlockCloseRegex(int $type): void /** * @return iterable<int> */ - public function blockTypesWithValidCloserRegexes(): iterable + public static function blockTypesWithValidCloserRegexes(): iterable { yield [HtmlBlock::TYPE_1_CODE_CONTAINER]; yield [HtmlBlock::TYPE_2_COMMENT]; @@ -380,7 +380,7 @@ public function testInvalidHtmlBlockCloseRegex(int $type): void /** * @return iterable<int> */ - public function blockTypesWithInvalidCloserRegexes(): iterable + public static function blockTypesWithInvalidCloserRegexes(): iterable { yield [HtmlBlock::TYPE_6_BLOCK_ELEMENT]; yield [HtmlBlock::TYPE_7_MISC_ELEMENT]; diff --git a/tests/unit/Util/UrlEncoderTest.php b/tests/unit/Util/UrlEncoderTest.php index fa5de02b8b..8a26500fdb 100644 --- a/tests/unit/Util/UrlEncoderTest.php +++ b/tests/unit/Util/UrlEncoderTest.php @@ -33,7 +33,7 @@ public function testUnescapeAndEncode(string $input, string $expected): void /** * @return iterable<array<string>> */ - public function unescapeAndEncodeTestProvider(): iterable + public static function unescapeAndEncodeTestProvider(): iterable { return [ ['(foo)', '(foo)'], diff --git a/tests/unit/Util/XmlTest.php b/tests/unit/Util/XmlTest.php index 3a02c00ddd..2020af8dc4 100644 --- a/tests/unit/Util/XmlTest.php +++ b/tests/unit/Util/XmlTest.php @@ -32,7 +32,7 @@ public function testEscape(string $input, string $expectedOutput): void /** * @return iterable<string[]> */ - public function dataProviderForTestEscape(): iterable + public static function dataProviderForTestEscape(): iterable { yield ['foo', 'foo']; yield ['©', '&copy;']; From f86992937e92f71d38fc439a3c3d9e1cc1378959 Mon Sep 17 00:00:00 2001 From: Colin O'Dell <colinodell@gmail.com> Date: Wed, 15 Feb 2023 10:18:42 -0500 Subject: [PATCH 3/7] PHPUnit 10 configuration --- .gitignore | 1 + phpunit.xml.dist | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 77fe2f60b0..785947a034 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.idea/ /.phpcs-cache /.phpunit.result.cache +/.phpunit.cache /build/ /docs/_site/ composer.lock diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0f3ae7d815..86eee9a77f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,15 +2,12 @@ <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" - backupStaticAttributes="false" + backupStaticProperties="false" colors="true" - verbose="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + cacheDirectory=".phpunit.cache" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"> <coverage> <include> <directory suffix=".php">src/</directory> From 2c9a1924a679d4865e1caf6a922a1f1fc879ec59 Mon Sep 17 00:00:00 2001 From: Colin O'Dell <codell@seatgeek.com> Date: Fri, 2 Feb 2024 06:36:41 -0500 Subject: [PATCH 4/7] Bump phpunit 10 min versino --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 398df2fdce..fad3749621 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "michelf/php-markdown": "^1.4 || ^2.0", "nyholm/psr7": "^1.5", "phpstan/phpstan": "^1.8.2", - "phpunit/phpunit": "^9.5.21 || ^10.0.7", + "phpunit/phpunit": "^9.5.21 || ^10.5.9", "scrutinizer/ocular": "^1.8.1", "symfony/finder": "^5.3 | ^6.0 || ^7.0", "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 || ^7.0", From 035aea84f26e3eb376f0249c704517289d05583f Mon Sep 17 00:00:00 2001 From: Colin O'Dell <codell@seatgeek.com> Date: Fri, 2 Feb 2024 06:49:54 -0500 Subject: [PATCH 5/7] Make test param names align with data provider --- tests/functional/AbstractSpecTestCase.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/functional/AbstractSpecTestCase.php b/tests/functional/AbstractSpecTestCase.php index 284e396cc4..86cf6dd52b 100644 --- a/tests/functional/AbstractSpecTestCase.php +++ b/tests/functional/AbstractSpecTestCase.php @@ -32,19 +32,19 @@ protected function setUp(): void /** * @dataProvider dataProvider * - * @param string $markdown Markdown to parse - * @param string $html Expected result + * @param string $input Markdown to parse + * @param string $output Expected result */ - public function testSpecExample(string $markdown, string $html): void + public function testSpecExample(string $input, string $output, string $type = '', string $section = '', int $number = -1): void { - $actualResult = (string) $this->converter->convert($markdown); + $actualResult = (string) $this->converter->convert($input); $failureMessage = 'Unexpected result:'; - $failureMessage .= "\n=== markdown ===============\n" . $this->showSpaces($markdown); - $failureMessage .= "\n=== expected ===============\n" . $this->showSpaces($html); + $failureMessage .= "\n=== markdown ===============\n" . $this->showSpaces($input); + $failureMessage .= "\n=== expected ===============\n" . $this->showSpaces($output); $failureMessage .= "\n=== got ====================\n" . $this->showSpaces($actualResult); - $this->assertEquals($html, $actualResult, $failureMessage); + $this->assertEquals($output, $actualResult, $failureMessage); } abstract public static function dataProvider(): \Generator; From 7497619c5b136e3299a59ecaab2fbd8c13121800 Mon Sep 17 00:00:00 2001 From: Colin O'Dell <codell@seatgeek.com> Date: Fri, 2 Feb 2024 06:50:16 -0500 Subject: [PATCH 6/7] Fix str_replace not targeting the right array element --- tests/functional/CMarkRegressionTest.php | 6 +++--- tests/functional/CommonMarkJSRegressionTest.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/functional/CMarkRegressionTest.php b/tests/functional/CMarkRegressionTest.php index d8f3ffb2f2..16ae72a1de 100644 --- a/tests/functional/CMarkRegressionTest.php +++ b/tests/functional/CMarkRegressionTest.php @@ -30,10 +30,10 @@ public static function dataProvider(): \Generator // We can't currently render spec example 13 exactly how the upstream library does. We'll likely need to overhaul // our rendering approach in order to fix that, so we'll use this temporary workaround for now. if ($example['number'] === 13) { - yield \str_replace('</script></li>', "</script>\n</li>", $example); - } else { - yield $example; + $example['output'] = \str_replace('</script></li>', "</script>\n</li>", $example['output']); } + + yield $example; } } } diff --git a/tests/functional/CommonMarkJSRegressionTest.php b/tests/functional/CommonMarkJSRegressionTest.php index bc8e3e93a6..5806cac006 100644 --- a/tests/functional/CommonMarkJSRegressionTest.php +++ b/tests/functional/CommonMarkJSRegressionTest.php @@ -30,10 +30,10 @@ public static function dataProvider(): \Generator // We can't currently render spec example 18 exactly how the upstream library does. We'll likely need to overhaul // our rendering approach in order to fix that, so we'll use this temporary workaround for now. if ($example['number'] === 18) { - yield \str_replace('</script></li>', "</script>\n</li>", $example); - } else { - yield $example; + $example['output'] = \str_replace('</script></li>', "</script>\n</li>", $example['output']); } + + yield $example; } } } From fc73c3407d716af2801c05c70d879c78b67f69ca Mon Sep 17 00:00:00 2001 From: Colin O'Dell <codell@seatgeek.com> Date: Fri, 2 Feb 2024 06:50:37 -0500 Subject: [PATCH 7/7] Allow testing with phpunit 11 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fad3749621..53901ebb7a 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "michelf/php-markdown": "^1.4 || ^2.0", "nyholm/psr7": "^1.5", "phpstan/phpstan": "^1.8.2", - "phpunit/phpunit": "^9.5.21 || ^10.5.9", + "phpunit/phpunit": "^9.5.21 || ^10.5.9 || ^11.0.0", "scrutinizer/ocular": "^1.8.1", "symfony/finder": "^5.3 | ^6.0 || ^7.0", "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 || ^7.0",