-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generators: add initial set of tests #671
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I left a few comments related to the Generator test. One that might require some changes if I'm not missing something.
These new tests safeguard the output generated by the `Text`, `Markdown` and `HTML` doc generators and the logic in the abstract `Generator` class. **Notes about the setup for these tests**: These tests use a set of test fixtures specially crafted for these tests. The use of fixtures means that the tests don't use _real_ documentation as included with the various standards, which is subject to change and would make the tests unstable. As the test fixtures are set up as an external standard, these tests will not only safeguard that doc generation works as expected, but also that it continues to work with external standards. This should help prevent issues as previously fixed in a10bea6 and e5bdaad. The footer output for the `Markdown` and `HTML` generators contains a date and a PHPCS version nr, which, again, would make the tests unstable. To mitigate this, test double classes are included for these classes, which overload the `printFooter()` methods and replaces the date and PHPCS version number with placeholders for the generic documentation tests. The _real_ footer is still tested, but via a regex pattern in a separate test in the `MarkdownTest` and `HTMLTest` classes. Finally, as things were, the tests for `Markdown` and `HTML` would fail on Windows due to the generated output containing mixed line endings in the HTML `<style>` tag and in the code samples for both. Commit 85b4a90 previously changed the EOL char used for output to screen to `PHP_EOL`, but these two places were overlooked. That is now fixed via this commit.
After #663, I'm going to add the I'll also rebase the PR (without changes other than the one mentioned above), as the CI setup has undergone some changes and some new required builds are missing. Once the build has passed, I'll get this merged. |
e7fa943
to
c883660
Compare
These new tests safeguard the output generated by the `Text`, `Markdown` and `HTML` doc generators and the logic in the abstract `Generator` class. **Notes about the setup for these tests**: These tests use a set of test fixtures specially crafted for these tests. The use of fixtures means that the tests don't use _real_ documentation as included with the various standards, which is subject to change and would make the tests unstable. As the test fixtures are set up as an external standard, these tests will not only safeguard that doc generation works as expected, but also that it continues to work with external standards. This should help prevent issues as previously fixed in a10bea6 and e5bdaad. The footer output for the `Markdown` and `HTML` generators contains a date and a PHPCS version nr, which, again, would make the tests unstable. To mitigate this, test double classes are included for these classes, which overload the `printFooter()` methods and replaces the date and PHPCS version number with placeholders for the generic documentation tests. The _real_ footer is still tested, but via a regex pattern in a separate test in the `MarkdownTest` and `HTMLTest` classes. Finally, as things were, the tests for `Markdown` and `HTML` would fail on Windows due to the generated output containing mixed line endings in the HTML `<style>` tag and in the code samples for both. Commit 85b4a90 previously changed the EOL char used for output to screen to `PHP_EOL`, but these two places were overlooked. That is now fixed via this commit.
Description
These new tests safeguard the output generated by the
Text
,Markdown
andHTML
doc generators and the logic in the abstractGenerator
class.Notes about the setup for these tests:
These tests use a set of test fixtures specially crafted for these tests. The use of fixtures means that the tests don't use real documentation as included with the various standards, which is subject to change and would make the tests unstable.
As the test fixtures are set up as an external standard, these tests will not only safeguard that doc generation works as expected, but also that it continues to work with external standards. This should help prevent issues as previously fixed in a10bea6 and e5bdaad.
The footer output for the
Markdown
andHTML
generators contains a date and a PHPCS version nr, which, again, would make the tests unstable. To mitigate this, test double classes are included for these classes, which overload theprintFooter()
methods and replace the date and PHPCS version number with placeholders for the generic documentation tests.The real footer is still tested, but via a regex pattern in a separate test in the
MarkdownTest
andHTMLTest
classes.Finally, as things were, the tests for
Markdown
andHTML
would fail on Windows due to the generated output containing mixed line endings in the HTML<style>
tag and in the code samples for both.Commit 85b4a90 previously changed the EOL char used for output to screen to
PHP_EOL
, but these two places were overlooked. That is now fixed via this commit.Suggested changelog entry
--generator=...
feature will respect the expected EOL, based on the OS on which PHPCS is run, in more places.Related issues/external references
This PR is part of a series of PRs which will add a complete set of tests for the Generator feature.
Related to #146
Types of changes