From cb831fbb43d7992db7b4c3ed3d8937a31561dbd8 Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Tue, 20 Nov 2018 22:47:28 +0000 Subject: [PATCH] Playing around with a new way to organize functional tests. --- composer.json | 3 +- composer.lock | 47 +- tests/Functional/FunctionalTest.php | 135 ++++ .../tests/anchor-failure/anchor-failure.html | 1 + .../tests/anchor-failure}/anchor-failure.rst | 0 tests/Functional/tests/anchor/anchor.html | 8 + .../tests/anchor}/anchor.rst | 0 tests/Functional/tests/anchor/anchor.tex | 3 + .../Functional/tests/anonymous/anonymous.html | 1 + .../tests/anonymous}/anonymous.rst | 2 - .../Functional/tests/anonymous/anonymous.tex | 1 + tests/Functional/tests/bom/bom.html | 1 + .../files => Functional/tests/bom}/bom.rst | 0 .../class-directive/class-directive.html | 35 + .../class-directive}/class-directive.rst | 0 .../code-block-lastline.html | 3 + .../code-block-lastline.rst | 5 + .../tests/code-block/code-block.html | 4 + .../tests/code-block}/code-block.rst | 1 - .../Functional/tests/code-java/code-java.html | 4 + .../tests/code-java}/code-java.rst | 1 - .../Functional/tests/code-list/code-list.html | 3 + .../tests/code-list}/code-list.rst | 1 - .../code-with-whitespace.html | 4 + .../code-with-whitespace.rst | 3 + tests/Functional/tests/code/code.html | 3 + .../files => Functional/tests/code}/code.rst | 1 - tests/Functional/tests/code/code.tex | 8 + .../Functional/tests/comment-3/comment-3.html | 1 + .../tests/comment-3}/comment-3.rst | 2 - tests/Functional/tests/comment/comment.html | 2 + tests/Functional/tests/comment/comment.rst | 3 + tests/Functional/tests/comments/comments.html | 1 + .../tests/comments}/comments.rst | 0 tests/Functional/tests/crlf/crlf.html | 6 + .../files => Functional/tests/crlf}/crlf.rst | 2 +- tests/Functional/tests/css/css.html | 1 + .../files => Functional/tests/css}/css.rst | 1 - .../definition-list/definition-list.html | 75 ++ .../tests/definition-list/definition-list.rst | 75 ++ .../directive-title/directive-title.html | 7 + .../directive-title}/directive-title.rst | 2 - tests/Functional/tests/div/div.html | 3 + .../files => Functional/tests/div}/div.rst | 1 - tests/Functional/tests/empty-p/empty-p.html | 6 + .../tests/empty-p}/empty-p.rst | 1 - tests/Functional/tests/empty/empty.html | 0 tests/Functional/tests/empty/empty.rst | 0 tests/Functional/tests/escape/escape.html | 1 + .../tests/escape}/escape.rst | 2 - tests/Functional/tests/figure/figure.html | 6 + .../tests/figure}/figure.rst | 1 - .../tests/image-follow/image-follow.html | 2 + .../tests/image-follow}/image-follow.rst | 2 - .../tests/image-inline/image-inline.html | 5 + .../tests/image-inline}/image-inline.rst | 2 - tests/Functional/tests/image/image.html | 3 + .../tests/image}/image.rst | 0 tests/Functional/tests/image/image.tex | 3 + .../tests/include-comments/comments.rst | 3 + .../include-comments/include-comments.html | 0 .../include-comments}/include-comments.rst | 2 - .../include-external/include-external.html | 1 + .../include-external/include-external.rst | 1 + .../tests/indented-list/indented-list.html | 7 + .../tests/indented-list}/indented-list.rst | 2 - tests/Functional/tests/italic/italic.html | 1 + .../tests/italic}/italic.rst | 2 - .../Functional/tests/link-span/link-span.html | 3 + .../Functional/tests/link-span/link-span.rst | 1 + .../link-with-new-line-inside-list.html | 4 + .../link-with-new-line-inside-list.rst | 0 .../link-with-new-line.html | 1 + .../link-with-new-line.rst | 0 .../link-with-no-name/link-with-no-name.html | 1 + .../link-with-no-name}/link-with-no-name.rst | 0 .../link-with-special-char.html | 1 + .../link-with-special-char.rst | 0 tests/Functional/tests/links/links.html | 11 + .../tests/links}/links.rst | 1 - .../list-alternate-syntax.html | 10 + .../list-alternate-syntax.rst | 0 .../Functional/tests/list-dash/list-dash.html | 4 + .../tests/list-dash}/list-dash.rst | 2 - .../tests/list-empty/list-empty.html | 11 + .../tests/list-empty}/list-empty.rst | 1 - tests/Functional/tests/list/list.html | 7 + .../files => Functional/tests/list}/list.rst | 4 +- tests/Functional/tests/list/list.tex | 7 + tests/Functional/tests/literal/literal.html | 1 + .../tests/literal}/literal.rst | 2 - .../tests/main-directive/main-directive.html | 2 + .../tests/main-directive/main-directive.rst} | 0 .../tests/main-directive/main-directive.tex | 17 + tests/Functional/tests/nbsp/nbsp.html | 1 + .../files => Functional/tests/nbsp}/nbsp.rst | 1 - .../no-eager-literals/no-eager-literals.html | 1 + .../no-eager-literals}/no-eager-literals.rst | 0 tests/Functional/tests/ordered/ordered.html | 6 + .../tests/ordered}/ordered.rst | 2 - tests/Functional/tests/ordered2/ordered2.html | 7 + .../tests/ordered2}/ordered2.rst | 2 - .../Functional/tests/paragraph/paragraph.html | 5 + .../Functional/tests/paragraph/paragraph.rst | 7 + .../Functional/tests/paragraph/paragraph.tex | 5 + .../pretty-table-header.html | 22 + .../pretty-table-header.rst | 2 - .../pretty-table-no-header.html | 15 + .../pretty-table-no-header.rst | 2 - .../tests/quote-title/quote-title.html | 14 + .../tests/quote-title}/quote-title.rst | 2 - tests/Functional/tests/quote/quote.html | 5 + .../tests/quote}/quote.rst | 0 tests/Functional/tests/quote/quote.tex | 6 + tests/Functional/tests/quote2/quote2.html | 5 + .../tests/quote2}/quote2.rst | 1 - tests/Functional/tests/quote3/quote3.html | 4 + .../tests/quote3}/quote3.rst | 1 - tests/Functional/tests/raw/raw.html | 2 + .../files => Functional/tests/raw}/raw.rst | 2 - .../section-nesting/section-nesting.html | 50 ++ .../tests/section-nesting/section-nesting.rst | 29 + .../Functional/tests/separator/separator.html | 3 + .../tests/separator}/separator.rst | 0 .../tests/separator/separator.tex} | 7 +- .../simple-table-error.html | 8 + .../simple-table-error.rst | 1 - .../tests/simple-table/simple-table.html | 21 + .../tests/simple-table}/simple-table.rst | 3 - .../standalone-email-addresses.html | 121 +++ .../standalone-email-addresses.rst | 0 .../standalone-hyperlinks.html | 35 + .../standalone-hyperlinks.rst | 0 tests/Functional/tests/strong/strong.html | 1 + .../tests/strong}/strong.rst | 2 - .../table-nested-list/table-nested-list.html | 21 + .../table-nested-list}/table-nested-list.rst | 2 - tests/Functional/tests/table/table.html | 21 + .../tests/table}/table.rst | 0 tests/Functional/tests/table/table.tex | 10 + .../tests/titles-auto/titles-auto.html | 38 + .../tests/titles-auto}/titles-auto.rst | 2 - tests/Functional/tests/titles/titles.html | 49 ++ .../tests/titles}/titles.rst | 1 - tests/Functional/tests/titles/titles.tex | 29 + .../unknown-directive/unknown-directive.html | 2 + .../unknown-directive}/unknown-directive.rst | 2 - .../tests/variable-wrap/variable-wrap.html | 10 + .../tests/variable-wrap}/variable-wrap.rst | 2 - tests/Functional/tests/wrap/wrap.html | 2 + .../files => Functional/tests/wrap}/wrap.rst | 1 - tests/HTML/HTMLTest.php | 723 ------------------ tests/HTML/files/image.rst | 8 - tests/HTML/files/include-external.rst | 1 - tests/HTML/files/link-span.rst | 3 - tests/HTML/files/quote.rst | 7 - tests/LaTeX/LaTeXTest.php | 214 ------ tests/LaTeX/files/anchor.rst | 3 - tests/LaTeX/files/code.rst | 6 - tests/LaTeX/files/list.rst | 5 - tests/LaTeX/files/paragraph.rst | 1 - tests/LaTeX/files/title.rst | 2 - tests/LaTeX/files/toc.rst | 9 - tests/Parser/ParserTest.php | 103 --- tests/Parser/files/inclusion-policy.rst | 2 +- tests/StandaloneLinksTest.php | 211 ----- 166 files changed, 1123 insertions(+), 1372 deletions(-) create mode 100644 tests/Functional/FunctionalTest.php create mode 100644 tests/Functional/tests/anchor-failure/anchor-failure.html rename tests/{HTML/files => Functional/tests/anchor-failure}/anchor-failure.rst (100%) create mode 100644 tests/Functional/tests/anchor/anchor.html rename tests/{HTML/files => Functional/tests/anchor}/anchor.rst (100%) create mode 100644 tests/Functional/tests/anchor/anchor.tex create mode 100644 tests/Functional/tests/anonymous/anonymous.html rename tests/{HTML/files => Functional/tests/anonymous}/anonymous.rst (95%) create mode 100644 tests/Functional/tests/anonymous/anonymous.tex create mode 100644 tests/Functional/tests/bom/bom.html rename tests/{HTML/files => Functional/tests/bom}/bom.rst (100%) create mode 100644 tests/Functional/tests/class-directive/class-directive.html rename tests/{HTML/files => Functional/tests/class-directive}/class-directive.rst (100%) create mode 100644 tests/Functional/tests/code-block-lastline/code-block-lastline.html create mode 100644 tests/Functional/tests/code-block-lastline/code-block-lastline.rst create mode 100644 tests/Functional/tests/code-block/code-block.html rename tests/{HTML/files => Functional/tests/code-block}/code-block.rst (99%) create mode 100644 tests/Functional/tests/code-java/code-java.html rename tests/{HTML/files => Functional/tests/code-java}/code-java.rst (98%) create mode 100644 tests/Functional/tests/code-list/code-list.html rename tests/{HTML/files => Functional/tests/code-list}/code-list.rst (98%) create mode 100644 tests/Functional/tests/code-with-whitespace/code-with-whitespace.html create mode 100644 tests/Functional/tests/code-with-whitespace/code-with-whitespace.rst create mode 100644 tests/Functional/tests/code/code.html rename tests/{HTML/files => Functional/tests/code}/code.rst (98%) create mode 100644 tests/Functional/tests/code/code.tex create mode 100644 tests/Functional/tests/comment-3/comment-3.html rename tests/{HTML/files => Functional/tests/comment-3}/comment-3.rst (96%) create mode 100644 tests/Functional/tests/comment/comment.html create mode 100644 tests/Functional/tests/comment/comment.rst create mode 100644 tests/Functional/tests/comments/comments.html rename tests/{HTML/files => Functional/tests/comments}/comments.rst (100%) create mode 100644 tests/Functional/tests/crlf/crlf.html rename tests/{HTML/files => Functional/tests/crlf}/crlf.rst (88%) create mode 100644 tests/Functional/tests/css/css.html rename tests/{HTML/files => Functional/tests/css}/css.rst (97%) create mode 100644 tests/Functional/tests/definition-list/definition-list.html create mode 100644 tests/Functional/tests/definition-list/definition-list.rst create mode 100644 tests/Functional/tests/directive-title/directive-title.html rename tests/{HTML/files => Functional/tests/directive-title}/directive-title.rst (94%) create mode 100644 tests/Functional/tests/div/div.html rename tests/{HTML/files => Functional/tests/div}/div.rst (96%) create mode 100644 tests/Functional/tests/empty-p/empty-p.html rename tests/{HTML/files => Functional/tests/empty-p}/empty-p.rst (97%) create mode 100644 tests/Functional/tests/empty/empty.html create mode 100644 tests/Functional/tests/empty/empty.rst create mode 100644 tests/Functional/tests/escape/escape.html rename tests/{HTML/files => Functional/tests/escape}/escape.rst (95%) create mode 100644 tests/Functional/tests/figure/figure.html rename tests/{HTML/files => Functional/tests/figure}/figure.rst (98%) create mode 100644 tests/Functional/tests/image-follow/image-follow.html rename tests/{HTML/files => Functional/tests/image-follow}/image-follow.rst (93%) create mode 100644 tests/Functional/tests/image-inline/image-inline.html rename tests/{HTML/files => Functional/tests/image-inline}/image-inline.rst (96%) create mode 100644 tests/Functional/tests/image/image.html rename tests/{LaTeX/files => Functional/tests/image}/image.rst (100%) create mode 100644 tests/Functional/tests/image/image.tex create mode 100644 tests/Functional/tests/include-comments/comments.rst create mode 100644 tests/Functional/tests/include-comments/include-comments.html rename tests/{HTML/files => Functional/tests/include-comments}/include-comments.rst (92%) create mode 100644 tests/Functional/tests/include-external/include-external.html create mode 100644 tests/Functional/tests/include-external/include-external.rst create mode 100644 tests/Functional/tests/indented-list/indented-list.html rename tests/{HTML/files => Functional/tests/indented-list}/indented-list.rst (98%) create mode 100644 tests/Functional/tests/italic/italic.html rename tests/{HTML/files => Functional/tests/italic}/italic.rst (96%) create mode 100644 tests/Functional/tests/link-span/link-span.html create mode 100644 tests/Functional/tests/link-span/link-span.rst create mode 100644 tests/Functional/tests/link-with-new-line-inside-list/link-with-new-line-inside-list.html rename tests/{HTML/files => Functional/tests/link-with-new-line-inside-list}/link-with-new-line-inside-list.rst (100%) create mode 100644 tests/Functional/tests/link-with-new-line/link-with-new-line.html rename tests/{HTML/files => Functional/tests/link-with-new-line}/link-with-new-line.rst (100%) create mode 100644 tests/Functional/tests/link-with-no-name/link-with-no-name.html rename tests/{HTML/files => Functional/tests/link-with-no-name}/link-with-no-name.rst (100%) create mode 100644 tests/Functional/tests/link-with-special-char/link-with-special-char.html rename tests/{HTML/files => Functional/tests/link-with-special-char}/link-with-special-char.rst (100%) create mode 100644 tests/Functional/tests/links/links.html rename tests/{HTML/files => Functional/tests/links}/links.rst (99%) create mode 100644 tests/Functional/tests/list-alternate-syntax/list-alternate-syntax.html rename tests/{HTML/files => Functional/tests/list-alternate-syntax}/list-alternate-syntax.rst (100%) create mode 100644 tests/Functional/tests/list-dash/list-dash.html rename tests/{HTML/files => Functional/tests/list-dash}/list-dash.rst (93%) create mode 100644 tests/Functional/tests/list-empty/list-empty.html rename tests/{HTML/files => Functional/tests/list-empty}/list-empty.rst (99%) create mode 100644 tests/Functional/tests/list/list.html rename tests/{HTML/files => Functional/tests/list}/list.rst (82%) create mode 100644 tests/Functional/tests/list/list.tex create mode 100644 tests/Functional/tests/literal/literal.html rename tests/{HTML/files => Functional/tests/literal}/literal.rst (97%) create mode 100644 tests/Functional/tests/main-directive/main-directive.html rename tests/{LaTeX/files/main.rst => Functional/tests/main-directive/main-directive.rst} (100%) create mode 100644 tests/Functional/tests/main-directive/main-directive.tex create mode 100644 tests/Functional/tests/nbsp/nbsp.html rename tests/{HTML/files => Functional/tests/nbsp}/nbsp.rst (97%) create mode 100644 tests/Functional/tests/no-eager-literals/no-eager-literals.html rename tests/{HTML/files => Functional/tests/no-eager-literals}/no-eager-literals.rst (100%) create mode 100644 tests/Functional/tests/ordered/ordered.html rename tests/{HTML/files => Functional/tests/ordered}/ordered.rst (97%) create mode 100644 tests/Functional/tests/ordered2/ordered2.html rename tests/{HTML/files => Functional/tests/ordered2}/ordered2.rst (98%) create mode 100644 tests/Functional/tests/paragraph/paragraph.html create mode 100644 tests/Functional/tests/paragraph/paragraph.rst create mode 100644 tests/Functional/tests/paragraph/paragraph.tex create mode 100644 tests/Functional/tests/pretty-table-header/pretty-table-header.html rename tests/{HTML/files => Functional/tests/pretty-table-header}/pretty-table-header.rst (99%) create mode 100644 tests/Functional/tests/pretty-table-no-header/pretty-table-no-header.html rename tests/{HTML/files => Functional/tests/pretty-table-no-header}/pretty-table-no-header.rst (99%) create mode 100644 tests/Functional/tests/quote-title/quote-title.html rename tests/{HTML/files => Functional/tests/quote-title}/quote-title.rst (97%) create mode 100644 tests/Functional/tests/quote/quote.html rename tests/{LaTeX/files => Functional/tests/quote}/quote.rst (100%) create mode 100644 tests/Functional/tests/quote/quote.tex create mode 100644 tests/Functional/tests/quote2/quote2.html rename tests/{HTML/files => Functional/tests/quote2}/quote2.rst (98%) create mode 100644 tests/Functional/tests/quote3/quote3.html rename tests/{HTML/files => Functional/tests/quote3}/quote3.rst (98%) create mode 100644 tests/Functional/tests/raw/raw.html rename tests/{HTML/files => Functional/tests/raw}/raw.rst (95%) create mode 100644 tests/Functional/tests/section-nesting/section-nesting.html create mode 100644 tests/Functional/tests/section-nesting/section-nesting.rst create mode 100644 tests/Functional/tests/separator/separator.html rename tests/{LaTeX/files => Functional/tests/separator}/separator.rst (100%) rename tests/{HTML/files/separator.rst => Functional/tests/separator/separator.tex} (63%) create mode 100644 tests/Functional/tests/simple-table-error/simple-table-error.html rename tests/{HTML/files => Functional/tests/simple-table-error}/simple-table-error.rst (99%) create mode 100644 tests/Functional/tests/simple-table/simple-table.html rename tests/{HTML/files => Functional/tests/simple-table}/simple-table.rst (98%) create mode 100644 tests/Functional/tests/standalone-email-addresses/standalone-email-addresses.html rename tests/{HTML/files => Functional/tests/standalone-email-addresses}/standalone-email-addresses.rst (100%) create mode 100644 tests/Functional/tests/standalone-hyperlinks/standalone-hyperlinks.html rename tests/{HTML/files => Functional/tests/standalone-hyperlinks}/standalone-hyperlinks.rst (100%) create mode 100644 tests/Functional/tests/strong/strong.html rename tests/{HTML/files => Functional/tests/strong}/strong.rst (94%) create mode 100644 tests/Functional/tests/table-nested-list/table-nested-list.html rename tests/{HTML/files => Functional/tests/table-nested-list}/table-nested-list.rst (99%) create mode 100644 tests/Functional/tests/table/table.html rename tests/{LaTeX/files => Functional/tests/table}/table.rst (100%) create mode 100644 tests/Functional/tests/table/table.tex create mode 100644 tests/Functional/tests/titles-auto/titles-auto.html rename tests/{HTML/files => Functional/tests/titles-auto}/titles-auto.rst (99%) create mode 100644 tests/Functional/tests/titles/titles.html rename tests/{HTML/files => Functional/tests/titles}/titles.rst (99%) create mode 100644 tests/Functional/tests/titles/titles.tex create mode 100644 tests/Functional/tests/unknown-directive/unknown-directive.html rename tests/{HTML/files => Functional/tests/unknown-directive}/unknown-directive.rst (92%) create mode 100644 tests/Functional/tests/variable-wrap/variable-wrap.html rename tests/{HTML/files => Functional/tests/variable-wrap}/variable-wrap.rst (96%) create mode 100644 tests/Functional/tests/wrap/wrap.html rename tests/{HTML/files => Functional/tests/wrap}/wrap.rst (97%) delete mode 100644 tests/HTML/HTMLTest.php delete mode 100644 tests/HTML/files/image.rst delete mode 100644 tests/HTML/files/include-external.rst delete mode 100644 tests/HTML/files/link-span.rst delete mode 100644 tests/HTML/files/quote.rst delete mode 100644 tests/LaTeX/LaTeXTest.php delete mode 100644 tests/LaTeX/files/anchor.rst delete mode 100644 tests/LaTeX/files/code.rst delete mode 100644 tests/LaTeX/files/list.rst delete mode 100644 tests/LaTeX/files/paragraph.rst delete mode 100644 tests/LaTeX/files/title.rst delete mode 100644 tests/LaTeX/files/toc.rst delete mode 100644 tests/StandaloneLinksTest.php diff --git a/composer.json b/composer.json index a13bb0f5..9de56ca2 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "phpstan/phpstan-deprecation-rules": "^0.10", "phpstan/phpstan-phpunit": "^0.10", "phpstan/phpstan-strict-rules": "^0.10", - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^7.0", + "gajus/dindent": "^2.0.2" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 76f80f46..327f8f08 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "02d81bf59fb882c99a726ee8e1972313", + "content-hash": "9a9422bcd2ec96aca6a4f646ac10f86c", "packages": [ { "name": "doctrine/event-manager", @@ -543,6 +543,51 @@ ], "time": "2017-07-22T11:58:36+00:00" }, + { + "name": "gajus/dindent", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/gajus/dindent.git", + "reference": "d81c3a6f78fbe1ab26f5e753098bbbef6b6a9f3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/gajus/dindent/zipball/d81c3a6f78fbe1ab26f5e753098bbbef6b6a9f3c", + "reference": "d81c3a6f78fbe1ab26f5e753098bbbef6b6a9f3c", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "satooshi/php-coveralls": "dev-master" + }, + "type": "library", + "autoload": { + "psr-4": { + "Gajus\\Dindent\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Gajus Kuizinas", + "email": "gk@anuary.com" + } + ], + "description": "HTML indentation library for development and testing.", + "homepage": "https://github.com/gajus/dindent", + "keywords": [ + "format", + "html", + "indent" + ], + "time": "2014-10-08T10:03:04+00:00" + }, { "name": "jean85/pretty-package-versions", "version": "1.2", diff --git a/tests/Functional/FunctionalTest.php b/tests/Functional/FunctionalTest.php new file mode 100644 index 00000000..d2151570 --- /dev/null +++ b/tests/Functional/FunctionalTest.php @@ -0,0 +1,135 @@ +expectException($exceptionClass); + + $expectedExceptionMessage = $expectedLines; + unset($expectedExceptionMessage[0]); + $expectedExceptionMessage = implode("\n", $expectedExceptionMessage); + + $this->expectExceptionMessage($expectedExceptionMessage); + } + + $document = $parser->parse($rst); + + $rendered = $document->$renderMethod(); + + if ($format === Format::HTML) { + $indenter = new Indenter(); + $rendered = $indenter->indent($rendered); + } + + self::assertSame( + $this->trimTrailingWhitespace($expected), + $this->trimTrailingWhitespace($rendered) + ); + } + + /** + * @return mixed[] + */ + public function getFunctionalTests() : array + { + $finder = new Finder(); + $finder + ->files() + ->in(__DIR__ . '/tests') + ->name('*.rst'); + + $tests = []; + + foreach ($finder as $file) { + $rst = $file->getContents(); + $filename = $file->getFilename(); + $basename = basename($filename, '.rst'); + + $dir = $file->getPathInfo(); + + $formats = [Format::HTML, Format::LATEX]; + + foreach ($formats as $format) { + $formatPath = $dir . '/' . $basename . '.' . $format; + + if (! file_exists($formatPath)) { + continue; + } + + $expected = file_get_contents($formatPath); + + if ($expected === false) { + continue; + } + + $configuration = new Configuration(); + $configuration->setFileExtension($format); + + $kernel = new Kernel($configuration); + $parser = new Parser($kernel); + + $environment = $parser->getEnvironment(); + $environment->setCurrentDirectory(__DIR__ . '/tests/' . $basename); + + $renderMethod = in_array($basename, self::RENDER_DOCUMENT_FILES, true) + ? 'renderDocument' + : 'render'; + + $tests[] = [$basename, $parser, $renderMethod, $format, $rst, trim($expected)]; + } + } + + return $tests; + } + + private function trimTrailingWhitespace(string $string) : string + { + $lines = explode("\n", $string); + + $lines = array_map(static function (string $line) { + return rtrim($line); + }, $lines); + + return trim(implode("\n", $lines)); + } +} diff --git a/tests/Functional/tests/anchor-failure/anchor-failure.html b/tests/Functional/tests/anchor-failure/anchor-failure.html new file mode 100644 index 00000000..fe92f3a2 --- /dev/null +++ b/tests/Functional/tests/anchor-failure/anchor-failure.html @@ -0,0 +1 @@ +

@Anchor Section

diff --git a/tests/HTML/files/anchor-failure.rst b/tests/Functional/tests/anchor-failure/anchor-failure.rst similarity index 100% rename from tests/HTML/files/anchor-failure.rst rename to tests/Functional/tests/anchor-failure/anchor-failure.rst diff --git a/tests/Functional/tests/anchor/anchor.html b/tests/Functional/tests/anchor/anchor.html new file mode 100644 index 00000000..c25547f0 --- /dev/null +++ b/tests/Functional/tests/anchor/anchor.html @@ -0,0 +1,8 @@ +
+

+ Anchors +

+ + +

go to lists

+
diff --git a/tests/HTML/files/anchor.rst b/tests/Functional/tests/anchor/anchor.rst similarity index 100% rename from tests/HTML/files/anchor.rst rename to tests/Functional/tests/anchor/anchor.rst diff --git a/tests/Functional/tests/anchor/anchor.tex b/tests/Functional/tests/anchor/anchor.tex new file mode 100644 index 00000000..c0c33e22 --- /dev/null +++ b/tests/Functional/tests/anchor/anchor.tex @@ -0,0 +1,3 @@ +\chapter{Anchors} +\label{lists} +\ref{#lists} diff --git a/tests/Functional/tests/anonymous/anonymous.html b/tests/Functional/tests/anonymous/anonymous.html new file mode 100644 index 00000000..7563db24 --- /dev/null +++ b/tests/Functional/tests/anonymous/anonymous.html @@ -0,0 +1 @@ +

I love GitHub

diff --git a/tests/HTML/files/anonymous.rst b/tests/Functional/tests/anonymous/anonymous.rst similarity index 95% rename from tests/HTML/files/anonymous.rst rename to tests/Functional/tests/anonymous/anonymous.rst index 75653d4e..7f510674 100644 --- a/tests/HTML/files/anonymous.rst +++ b/tests/Functional/tests/anonymous/anonymous.rst @@ -1,5 +1,3 @@ - I love GitHub__ .. __: http://www.github.com/ - diff --git a/tests/Functional/tests/anonymous/anonymous.tex b/tests/Functional/tests/anonymous/anonymous.tex new file mode 100644 index 00000000..6452be8e --- /dev/null +++ b/tests/Functional/tests/anonymous/anonymous.tex @@ -0,0 +1 @@ +I love \href{http://www.github.com/}{GitHub} diff --git a/tests/Functional/tests/bom/bom.html b/tests/Functional/tests/bom/bom.html new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/Functional/tests/bom/bom.html @@ -0,0 +1 @@ + diff --git a/tests/HTML/files/bom.rst b/tests/Functional/tests/bom/bom.rst similarity index 100% rename from tests/HTML/files/bom.rst rename to tests/Functional/tests/bom/bom.rst diff --git a/tests/Functional/tests/class-directive/class-directive.html b/tests/Functional/tests/class-directive/class-directive.html new file mode 100644 index 00000000..37ec2b10 --- /dev/null +++ b/tests/Functional/tests/class-directive/class-directive.html @@ -0,0 +1,35 @@ +

Test special-paragraph1 1.

+

Test special-paragraph1 2.

+

Test special-paragraph2 1.

+

Test special-paragraph2 2.

+
+

Test

+
+ +

Weird class names.

+

Level 1

+
+

Level2 1

+

Level2 2

+
+
+
term 1
+
Definition 1
+
+ + + + + + + + + + + + + +
First colSecond col
Second rowOther col
diff --git a/tests/HTML/files/class-directive.rst b/tests/Functional/tests/class-directive/class-directive.rst similarity index 100% rename from tests/HTML/files/class-directive.rst rename to tests/Functional/tests/class-directive/class-directive.rst diff --git a/tests/Functional/tests/code-block-lastline/code-block-lastline.html b/tests/Functional/tests/code-block-lastline/code-block-lastline.html new file mode 100644 index 00000000..26c6a075 --- /dev/null +++ b/tests/Functional/tests/code-block-lastline/code-block-lastline.html @@ -0,0 +1,3 @@ +
A
+B C
+
diff --git a/tests/Functional/tests/code-block-lastline/code-block-lastline.rst b/tests/Functional/tests/code-block-lastline/code-block-lastline.rst new file mode 100644 index 00000000..ae6adb94 --- /dev/null +++ b/tests/Functional/tests/code-block-lastline/code-block-lastline.rst @@ -0,0 +1,5 @@ +.. code-block:: + + A + B + C diff --git a/tests/Functional/tests/code-block/code-block.html b/tests/Functional/tests/code-block/code-block.html new file mode 100644 index 00000000..7f9e7768 --- /dev/null +++ b/tests/Functional/tests/code-block/code-block.html @@ -0,0 +1,4 @@ +
#include <iostream> using namespace std; int main(void)
+{ cout << "Hello world!" << endl;
+}
+
diff --git a/tests/HTML/files/code-block.rst b/tests/Functional/tests/code-block/code-block.rst similarity index 99% rename from tests/HTML/files/code-block.rst rename to tests/Functional/tests/code-block/code-block.rst index 31bde181..e2c5735d 100644 --- a/tests/HTML/files/code-block.rst +++ b/tests/Functional/tests/code-block/code-block.rst @@ -1,4 +1,3 @@ - .. code-block:: c++ #include diff --git a/tests/Functional/tests/code-java/code-java.html b/tests/Functional/tests/code-java/code-java.html new file mode 100644 index 00000000..60e0d5cf --- /dev/null +++ b/tests/Functional/tests/code-java/code-java.html @@ -0,0 +1,4 @@ +
protected void f()
+{
+}
+
diff --git a/tests/HTML/files/code-java.rst b/tests/Functional/tests/code-java/code-java.rst similarity index 98% rename from tests/HTML/files/code-java.rst rename to tests/Functional/tests/code-java/code-java.rst index 6787df9f..9a16919b 100644 --- a/tests/HTML/files/code-java.rst +++ b/tests/Functional/tests/code-java/code-java.rst @@ -1,4 +1,3 @@ - .. code-block:: java protected void f() diff --git a/tests/Functional/tests/code-list/code-list.html b/tests/Functional/tests/code-list/code-list.html new file mode 100644 index 00000000..e4c553f6 --- /dev/null +++ b/tests/Functional/tests/code-list/code-list.html @@ -0,0 +1,3 @@ +
* Testing
+* Hey
+
diff --git a/tests/HTML/files/code-list.rst b/tests/Functional/tests/code-list/code-list.rst similarity index 98% rename from tests/HTML/files/code-list.rst rename to tests/Functional/tests/code-list/code-list.rst index 131e87b8..3d6a0340 100644 --- a/tests/HTML/files/code-list.rst +++ b/tests/Functional/tests/code-list/code-list.rst @@ -1,4 +1,3 @@ - .. This should not be interpreted as a list .. code-block:: diff --git a/tests/Functional/tests/code-with-whitespace/code-with-whitespace.html b/tests/Functional/tests/code-with-whitespace/code-with-whitespace.html new file mode 100644 index 00000000..8379a491 --- /dev/null +++ b/tests/Functional/tests/code-with-whitespace/code-with-whitespace.html @@ -0,0 +1,4 @@ +
+
+

Test code block with whitespace.

+
diff --git a/tests/Functional/tests/code-with-whitespace/code-with-whitespace.rst b/tests/Functional/tests/code-with-whitespace/code-with-whitespace.rst new file mode 100644 index 00000000..7c4b0b33 --- /dev/null +++ b/tests/Functional/tests/code-with-whitespace/code-with-whitespace.rst @@ -0,0 +1,3 @@ +:: + + Test code block with whitespace. diff --git a/tests/Functional/tests/code/code.html b/tests/Functional/tests/code/code.html new file mode 100644 index 00000000..0c9e2364 --- /dev/null +++ b/tests/Functional/tests/code/code.html @@ -0,0 +1,3 @@ +

Code block:

+
This is a code block You hou!
+
diff --git a/tests/HTML/files/code.rst b/tests/Functional/tests/code/code.rst similarity index 98% rename from tests/HTML/files/code.rst rename to tests/Functional/tests/code/code.rst index 2dd00a2f..0ad7cea2 100644 --- a/tests/HTML/files/code.rst +++ b/tests/Functional/tests/code/code.rst @@ -1,4 +1,3 @@ - Code block:: This is a code block diff --git a/tests/Functional/tests/code/code.tex b/tests/Functional/tests/code/code.tex new file mode 100644 index 00000000..b299bd01 --- /dev/null +++ b/tests/Functional/tests/code/code.tex @@ -0,0 +1,8 @@ +Code block: +\lstset{language=} +\begin{lstlisting} +This is a code block + +You hou! + +\end{lstlisting} diff --git a/tests/Functional/tests/comment-3/comment-3.html b/tests/Functional/tests/comment-3/comment-3.html new file mode 100644 index 00000000..9133b5ec --- /dev/null +++ b/tests/Functional/tests/comment-3/comment-3.html @@ -0,0 +1 @@ +

... This is not a comment!

diff --git a/tests/HTML/files/comment-3.rst b/tests/Functional/tests/comment-3/comment-3.rst similarity index 96% rename from tests/HTML/files/comment-3.rst rename to tests/Functional/tests/comment-3/comment-3.rst index d8c7a28c..5922a5e0 100644 --- a/tests/HTML/files/comment-3.rst +++ b/tests/Functional/tests/comment-3/comment-3.rst @@ -1,4 +1,2 @@ - .. This is a comment! ... This is not a comment! - diff --git a/tests/Functional/tests/comment/comment.html b/tests/Functional/tests/comment/comment.html new file mode 100644 index 00000000..bb04776e --- /dev/null +++ b/tests/Functional/tests/comment/comment.html @@ -0,0 +1,2 @@ +

Text before

+

Text after

diff --git a/tests/Functional/tests/comment/comment.rst b/tests/Functional/tests/comment/comment.rst new file mode 100644 index 00000000..8c904de5 --- /dev/null +++ b/tests/Functional/tests/comment/comment.rst @@ -0,0 +1,3 @@ +Text before +.. Testing comment +Text after diff --git a/tests/Functional/tests/comments/comments.html b/tests/Functional/tests/comments/comments.html new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/Functional/tests/comments/comments.html @@ -0,0 +1 @@ + diff --git a/tests/HTML/files/comments.rst b/tests/Functional/tests/comments/comments.rst similarity index 100% rename from tests/HTML/files/comments.rst rename to tests/Functional/tests/comments/comments.rst diff --git a/tests/Functional/tests/crlf/crlf.html b/tests/Functional/tests/crlf/crlf.html new file mode 100644 index 00000000..08c1d048 --- /dev/null +++ b/tests/Functional/tests/crlf/crlf.html @@ -0,0 +1,6 @@ +
+

+ Hello world +

+

Hey!

+
diff --git a/tests/HTML/files/crlf.rst b/tests/Functional/tests/crlf/crlf.rst similarity index 88% rename from tests/HTML/files/crlf.rst rename to tests/Functional/tests/crlf/crlf.rst index 163efa8d..621b342c 100644 --- a/tests/HTML/files/crlf.rst +++ b/tests/Functional/tests/crlf/crlf.rst @@ -1,4 +1,4 @@ Hello world =========== -Hey! +Hey! diff --git a/tests/Functional/tests/css/css.html b/tests/Functional/tests/css/css.html new file mode 100644 index 00000000..85efa8f7 --- /dev/null +++ b/tests/Functional/tests/css/css.html @@ -0,0 +1 @@ +

Testing page!

diff --git a/tests/HTML/files/css.rst b/tests/Functional/tests/css/css.rst similarity index 97% rename from tests/HTML/files/css.rst rename to tests/Functional/tests/css/css.rst index 8275c4bd..d4803bfc 100644 --- a/tests/HTML/files/css.rst +++ b/tests/Functional/tests/css/css.rst @@ -1,4 +1,3 @@ - .. stylesheet:: style.css Testing page! diff --git a/tests/Functional/tests/definition-list/definition-list.html b/tests/Functional/tests/definition-list/definition-list.html new file mode 100644 index 00000000..4e5606d2 --- /dev/null +++ b/tests/Functional/tests/definition-list/definition-list.html @@ -0,0 +1,75 @@ +
+

+ Test +

+
+

Test

+
+

Text around the definition list.

+
+
term 1
+
Definition 1
+
term 2
+
+

Definition 1

+

Definition 2

+

Definition 3

+
+
term 3 :classifier
+
Definition 1
+
term 4 :classifier one:classifier two
+
Definition 1
+
term with & :classifier with &
+
Definition 1 with &
+
term with & :classifier with &:classifier with &
+
+

Definition 1 with &

+

Definition 2 with &

+
+
+ term 5: + classifier +
+
Definition 1
+
multi-line definition term
+
+

Definition 1 line 1 Definition 1 line 2

+

Definition 2 line 1 Definition 2 line 2

+
+
+
+
+

+ Definition List in a Directive +

+
+

Definition list in a directive

+
+
term 1
+
+

Definition 1 line 1 Definition 1 line 2

+

Definition 2

+
+
term 2
+
+

Definition 1 line 1 Definition 1 line 2

+

Definition 2

+
+
+
+
+
+

+ Definition List Surrounded by Paragraphs +

+

Paragraph 1

+
+
term 1
+
definition 1 definition 2
+
+

Paragraph 2

+
+
term 2
+
definition 1 definition 2
+
+
diff --git a/tests/Functional/tests/definition-list/definition-list.rst b/tests/Functional/tests/definition-list/definition-list.rst new file mode 100644 index 00000000..37b243dd --- /dev/null +++ b/tests/Functional/tests/definition-list/definition-list.rst @@ -0,0 +1,75 @@ +Test +==== + +.. note:: + Test + +Text around the definition list. + +term 1 + Definition 1 + +term 2 + Definition 1 + + Definition 2 + + Definition 3 + +term 3 : classifier + Definition 1 + +term 4 : classifier one : classifier two + Definition 1 + +term with & : classifier with & + Definition 1 with & + +term with & : classifier with & : classifier with & + Definition 1 with & + + Definition 2 with & + +``term 5`` : ``classifier`` + Definition 1 + +multi-line definition term + Definition 1 line 1 + Definition 1 line 2 + + Definition 2 line 1 + Definition 2 line 2 + +Definition List in a Directive +============================== + +.. note:: + + **Definition list in a directive** + + term 1 + Definition 1 line 1 + Definition 1 line 2 + + Definition 2 + + term 2 + Definition 1 line 1 + Definition 1 line 2 + + Definition 2 + +Definition List Surrounded by Paragraphs +========================================= + +Paragraph 1 + +term 1 + definition 1 + definition 2 + +Paragraph 2 + +term 2 + definition 1 + definition 2 diff --git a/tests/Functional/tests/directive-title/directive-title.html b/tests/Functional/tests/directive-title/directive-title.html new file mode 100644 index 00000000..52efe37d --- /dev/null +++ b/tests/Functional/tests/directive-title/directive-title.html @@ -0,0 +1,7 @@ +
+
+

+ Some title! +

+
+
diff --git a/tests/HTML/files/directive-title.rst b/tests/Functional/tests/directive-title/directive-title.rst similarity index 94% rename from tests/HTML/files/directive-title.rst rename to tests/Functional/tests/directive-title/directive-title.rst index 765c63e6..0890ede7 100644 --- a/tests/HTML/files/directive-title.rst +++ b/tests/Functional/tests/directive-title/directive-title.rst @@ -1,5 +1,3 @@ - .. note:: Some title! =========== - diff --git a/tests/Functional/tests/div/div.html b/tests/Functional/tests/div/div.html new file mode 100644 index 00000000..d92e8a68 --- /dev/null +++ b/tests/Functional/tests/div/div.html @@ -0,0 +1,3 @@ +
+

Hello!

+
diff --git a/tests/HTML/files/div.rst b/tests/Functional/tests/div/div.rst similarity index 96% rename from tests/HTML/files/div.rst rename to tests/Functional/tests/div/div.rst index a7ca1a67..0d13aa1e 100644 --- a/tests/HTML/files/div.rst +++ b/tests/Functional/tests/div/div.rst @@ -1,3 +1,2 @@ - .. div:: testing Hello! diff --git a/tests/Functional/tests/empty-p/empty-p.html b/tests/Functional/tests/empty-p/empty-p.html new file mode 100644 index 00000000..cb5e0a77 --- /dev/null +++ b/tests/Functional/tests/empty-p/empty-p.html @@ -0,0 +1,6 @@ +

Empty paragraph:

+
+
+

Code

+
+

Hello

diff --git a/tests/HTML/files/empty-p.rst b/tests/Functional/tests/empty-p/empty-p.rst similarity index 97% rename from tests/HTML/files/empty-p.rst rename to tests/Functional/tests/empty-p/empty-p.rst index bba01850..e1b85927 100644 --- a/tests/HTML/files/empty-p.rst +++ b/tests/Functional/tests/empty-p/empty-p.rst @@ -1,4 +1,3 @@ - Empty paragraph: :: diff --git a/tests/Functional/tests/empty/empty.html b/tests/Functional/tests/empty/empty.html new file mode 100644 index 00000000..e69de29b diff --git a/tests/Functional/tests/empty/empty.rst b/tests/Functional/tests/empty/empty.rst new file mode 100644 index 00000000..e69de29b diff --git a/tests/Functional/tests/escape/escape.html b/tests/Functional/tests/escape/escape.html new file mode 100644 index 00000000..e44a0ef0 --- /dev/null +++ b/tests/Functional/tests/escape/escape.html @@ -0,0 +1 @@ +

Testing that this is escaped: <script>

diff --git a/tests/HTML/files/escape.rst b/tests/Functional/tests/escape/escape.rst similarity index 95% rename from tests/HTML/files/escape.rst rename to tests/Functional/tests/escape/escape.rst index 4ec31eac..196efc79 100644 --- a/tests/HTML/files/escape.rst +++ b/tests/Functional/tests/escape/escape.rst @@ -1,3 +1 @@ - Testing that this is escaped: