1818
1919use League \CommonMark \CommonMarkConverter ;
2020use League \CommonMark \MarkdownConverter ;
21- use League \CommonMark \Util \SpecReader ;
2221use PHPUnit \Framework \TestCase ;
2322
24- abstract class AbstractSpecTest extends TestCase
23+ abstract class AbstractSpecTestCase extends TestCase
2524{
2625 protected MarkdownConverter $ converter ;
2726
@@ -33,35 +32,25 @@ protected function setUp(): void
3332 /**
3433 * @dataProvider dataProvider
3534 *
36- * @param string $markdown Markdown to parse
37- * @param string $html Expected result
35+ * @param string $input Markdown to parse
36+ * @param string $output Expected result
3837 */
39- public function testSpecExample (string $ markdown , string $ html ): void
38+ public function testSpecExample (string $ input , string $ output , string $ type = '' , string $ section = '' , int $ number = - 1 ): void
4039 {
41- $ actualResult = (string ) $ this ->converter ->convert ($ markdown );
40+ $ actualResult = (string ) $ this ->converter ->convert ($ input );
4241
4342 $ failureMessage = 'Unexpected result: ' ;
44- $ failureMessage .= "\n=== markdown =============== \n" . $ this ->showSpaces ($ markdown );
45- $ failureMessage .= "\n=== expected =============== \n" . $ this ->showSpaces ($ html );
43+ $ failureMessage .= "\n=== markdown =============== \n" . $ this ->showSpaces ($ input );
44+ $ failureMessage .= "\n=== expected =============== \n" . $ this ->showSpaces ($ output );
4645 $ failureMessage .= "\n=== got ==================== \n" . $ this ->showSpaces ($ actualResult );
4746
48- $ this ->assertEquals ($ html , $ actualResult , $ failureMessage );
47+ $ this ->assertEquals ($ output , $ actualResult , $ failureMessage );
4948 }
5049
51- public function dataProvider (): \Generator
52- {
53- yield from $ this ->loadSpecExamples ();
54- }
55-
56- protected function loadSpecExamples (): \Generator
57- {
58- yield from SpecReader::readFile ($ this ->getFileName ());
59- }
50+ abstract public static function dataProvider (): \Generator ;
6051
6152 private function showSpaces (string $ str ): string
6253 {
6354 return \strtr ($ str , ["\t" => '→ ' , ' ' => '␣ ' ]);
6455 }
65-
66- abstract protected function getFileName (): string ;
6756}
0 commit comments