diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.html b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.html new file mode 100644 index 0000000000..fc35fdf0bf --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.html @@ -0,0 +1,118 @@ +<html> + <head> + <title>GeneratorTest Coding Standards</title> + <style> + body { + background-color: #FFFFFF; + font-size: 14px; + font-family: Arial, Helvetica, sans-serif; + color: #000000; + } + + h1 { + color: #666666; + font-size: 20px; + font-weight: bold; + margin-top: 0px; + background-color: #E6E7E8; + padding: 20px; + border: 1px solid #BBBBBB; + } + + h2 { + color: #00A5E3; + font-size: 16px; + font-weight: normal; + margin-top: 50px; + } + + .code-comparison { + width: 100%; + } + + .code-comparison td { + border: 1px solid #CCCCCC; + } + + .code-comparison-title, .code-comparison-code { + font-family: Arial, Helvetica, sans-serif; + font-size: 12px; + color: #000000; + vertical-align: top; + padding: 4px; + width: 50%; + background-color: #F1F1F1; + line-height: 15px; + } + + .code-comparison-code { + font-family: Courier; + background-color: #F9F9F9; + } + + .code-comparison-highlight { + background-color: #DDF1F7; + border: 1px solid #00A5E3; + line-height: 15px; + } + + .tag-line { + text-align: center; + width: 100%; + margin-top: 30px; + font-size: 12px; + } + + .tag-line a { + color: #000000; + } + </style> + </head> + <body> + <h1>GeneratorTest Coding Standards</h1> + <a name="Code-Title,-line-wrapping" /> + <h2>Code Title, line wrapping</h2> + <p class="text">This is a standard block.</p> + <table class="code-comparison"> + <tr> + <td class="code-comparison-title">Valid: exactly 45 character long description.</td> + <td class="code-comparison-title">Invalid: exactly 45 char long description---.</td> + </tr> + <tr> + <td class="code-comparison-code">// Dummy.</td> + <td class="code-comparison-code">// Dummy.</td> + </tr> + </table> + <table class="code-comparison"> + <tr> + <td class="code-comparison-title">Valid: exactly 46 character long description-.</td> + <td class="code-comparison-title">Invalid: exactly 46 character long description</td> + </tr> + <tr> + <td class="code-comparison-code">// Dummy.</td> + <td class="code-comparison-code">// Dummy.</td> + </tr> + </table> + <table class="code-comparison"> + <tr> + <td class="code-comparison-title">Valid: exactly 47 character long description--.</td> + <td class="code-comparison-title">Invalid: exactly 47 character long description.</td> + </tr> + <tr> + <td class="code-comparison-code">// Dummy.</td> + <td class="code-comparison-code">// Dummy.</td> + </tr> + </table> + <table class="code-comparison"> + <tr> + <td class="code-comparison-title">Valid: this description is longer than 46 characters and will wrap.</td> + <td class="code-comparison-title">Invalid: this description is longer than 46 characters and will wrap.</td> + </tr> + <tr> + <td class="code-comparison-code">// Dummy.</td> + <td class="code-comparison-code">// Dummy.</td> + </tr> + </table> + <div class="tag-line">Documentation generated on #REDACTED# by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer #VERSION#</a></div> + </body> +</html> diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.md new file mode 100644 index 0000000000..e5b7251aa2 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.md @@ -0,0 +1,78 @@ +# GeneratorTest Coding Standard + +## Code Title, line wrapping +This is a standard block. + <table> + <tr> + <th>Valid: exactly 45 character long description.</th> + <th>Invalid: exactly 45 char long description---.</th> + </tr> + <tr> +<td> + + // Dummy. + +</td> +<td> + + // Dummy. + +</td> + </tr> + </table> + <table> + <tr> + <th>Valid: exactly 46 character long description-.</th> + <th>Invalid: exactly 46 character long description</th> + </tr> + <tr> +<td> + + // Dummy. + +</td> +<td> + + // Dummy. + +</td> + </tr> + </table> + <table> + <tr> + <th>Valid: exactly 47 character long description--.</th> + <th>Invalid: exactly 47 character long description.</th> + </tr> + <tr> +<td> + + // Dummy. + +</td> +<td> + + // Dummy. + +</td> + </tr> + </table> + <table> + <tr> + <th>Valid: this description is longer than 46 characters and will wrap.</th> + <th>Invalid: this description is longer than 46 characters and will wrap.</th> + </tr> + <tr> +<td> + + // Dummy. + +</td> +<td> + + // Dummy. + +</td> + </tr> + </table> + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.txt b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.txt new file mode 100644 index 0000000000..11925c4cbb --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.txt @@ -0,0 +1,33 @@ + +------------------------------------------------------------ +| GENERATORTEST CODING STANDARD: CODE TITLE, LINE WRAPPING | +------------------------------------------------------------ + +This is a standard block. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: exactly 45 character long description. | Invalid: exactly 45 char long description---. | +---------------------------------------------------------------------------------------------------- +| // Dummy. | // Dummy. | +---------------------------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: exactly 46 character long description-. | Invalid: exactly 46 character long description | +---------------------------------------------------------------------------------------------------- +| // Dummy. | // Dummy. | +---------------------------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: exactly 47 character long | Invalid: exactly 47 character long | +| description--. | description. | +---------------------------------------------------------------------------------------------------- +| // Dummy. | // Dummy. | +---------------------------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: this description is longer than 46 | Invalid: this description is longer than 46 | +| characters and will wrap. | characters and will wrap. | +---------------------------------------------------------------------------------------------------- +| // Dummy. | // Dummy. | +---------------------------------------------------------------------------------------------------- + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html new file mode 100644 index 0000000000..a64cdb4deb --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html @@ -0,0 +1,98 @@ +<html> + <head> + <title>GeneratorTest Coding Standards</title> + <style> + body { + background-color: #FFFFFF; + font-size: 14px; + font-family: Arial, Helvetica, sans-serif; + color: #000000; + } + + h1 { + color: #666666; + font-size: 20px; + font-weight: bold; + margin-top: 0px; + background-color: #E6E7E8; + padding: 20px; + border: 1px solid #BBBBBB; + } + + h2 { + color: #00A5E3; + font-size: 16px; + font-weight: normal; + margin-top: 50px; + } + + .code-comparison { + width: 100%; + } + + .code-comparison td { + border: 1px solid #CCCCCC; + } + + .code-comparison-title, .code-comparison-code { + font-family: Arial, Helvetica, sans-serif; + font-size: 12px; + color: #000000; + vertical-align: top; + padding: 4px; + width: 50%; + background-color: #F1F1F1; + line-height: 15px; + } + + .code-comparison-code { + font-family: Courier; + background-color: #F9F9F9; + } + + .code-comparison-highlight { + background-color: #DDF1F7; + border: 1px solid #00A5E3; + line-height: 15px; + } + + .tag-line { + text-align: center; + width: 100%; + margin-top: 30px; + font-size: 12px; + } + + .tag-line a { + color: #000000; + } + </style> + </head> + <body> + <h1>GeneratorTest Coding Standards</h1> + <a name="Code-Title,-whitespace-handling" /> + <h2>Code Title, whitespace handling</h2> + <p class="text">This is a standard block.</p> + <table class="code-comparison"> + <tr> + <td class="code-comparison-title"> Valid: spaces at start of description.</td> + <td class="code-comparison-title">Invalid: spaces at end making line > 46 chars. </td> + </tr> + <tr> + <td class="code-comparison-code">// Dummy.</td> + <td class="code-comparison-code">// Dummy.</td> + </tr> + </table> + <table class="code-comparison"> + <tr> + <td class="code-comparison-title"> Valid: spaces at start + end of description. </td> + <td class="code-comparison-title">Invalid: spaces ' ' in description.</td> + </tr> + <tr> + <td class="code-comparison-code">// Note: description above without the</br>// trailing whitespace fits in 46 chars.</td> + <td class="code-comparison-code">// Dummy.</td> + </tr> + </table> + <div class="tag-line">Documentation generated on #REDACTED# by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer #VERSION#</a></div> + </body> +</html> diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md new file mode 100644 index 0000000000..509abf6720 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md @@ -0,0 +1,43 @@ +# GeneratorTest Coding Standard + +## Code Title, whitespace handling +This is a standard block. + <table> + <tr> + <th> Valid: spaces at start of description.</th> + <th>Invalid: spaces at end making line > 46 chars. </th> + </tr> + <tr> +<td> + + // Dummy. + +</td> +<td> + + // Dummy. + +</td> + </tr> + </table> + <table> + <tr> + <th> Valid: spaces at start + end of description. </th> + <th>Invalid: spaces ' ' in description.</th> + </tr> + <tr> +<td> + + // Note: description above without the + // trailing whitespace fits in 46 chars. + +</td> +<td> + + // Dummy. + +</td> + </tr> + </table> + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt new file mode 100644 index 0000000000..80a6cc690b --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt @@ -0,0 +1,22 @@ + +------------------------------------------------------------------ +| GENERATORTEST CODING STANDARD: CODE TITLE, WHITESPACE HANDLING | +------------------------------------------------------------------ + +This is a standard block. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: spaces at start of description. | Invalid: spaces at end making line > 46 chars. | +| | | +---------------------------------------------------------------------------------------------------- +| // Dummy. | // Dummy. | +---------------------------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: spaces at start + end of description. | Invalid: spaces ' ' in description. | +| | | +---------------------------------------------------------------------------------------------------- +| // Note: description above without the | // Dummy. | +| // trailing whitespace fits in 46 chars. | | +---------------------------------------------------------------------------------------------------- + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleLineWrappingStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleLineWrappingStandard.xml new file mode 100644 index 0000000000..b773f7a88c --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleLineWrappingStandard.xml @@ -0,0 +1,55 @@ +<documentation title="Code Title, line wrapping"> + <standard> + <![CDATA[ + This is a standard block. + ]]> + </standard> + <code_comparison> + <code title="Valid: exactly 45 character long description."> + <![CDATA[ +// Dummy. + ]]> + </code> + <code title="Invalid: exactly 45 char long description---."> + <![CDATA[ +// Dummy. + ]]> + </code> + </code_comparison> + <code_comparison> + <code title="Valid: exactly 46 character long description-."> + <![CDATA[ +// Dummy. + ]]> + </code> + <code title="Invalid: exactly 46 character long description"> + <![CDATA[ +// Dummy. + ]]> + </code> + </code_comparison> + <code_comparison> + <code title="Valid: exactly 47 character long description--."> + <![CDATA[ +// Dummy. + ]]> + </code> + <code title="Invalid: exactly 47 character long description."> + <![CDATA[ +// Dummy. + ]]> + </code> + </code_comparison> + <code_comparison> + <code title="Valid: this description is longer than 46 characters and will wrap."> + <![CDATA[ +// Dummy. + ]]> + </code> + <code title="Invalid: this description is longer than 46 characters and will wrap."> + <![CDATA[ +// Dummy. + ]]> + </code> + </code_comparison> +</documentation> diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleWhitespaceStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleWhitespaceStandard.xml new file mode 100644 index 0000000000..2829720259 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleWhitespaceStandard.xml @@ -0,0 +1,32 @@ +<documentation title="Code Title, whitespace handling"> + <standard> + <![CDATA[ + This is a standard block. + ]]> + </standard> + <code_comparison> + <code title=" Valid: spaces at start of description."> + <![CDATA[ +// Dummy. + ]]> + </code> + <code title="Invalid: spaces at end making line > 46 chars. "> + <![CDATA[ +// Dummy. + ]]> + </code> + </code_comparison> + <code_comparison> + <code title=" Valid: spaces at start + end of description. "> + <![CDATA[ +// Note: description above without the +// trailing whitespace fits in 46 chars. + ]]> + </code> + <code title="Invalid: spaces ' ' in description."> + <![CDATA[ +// Dummy. + ]]> + </code> + </code_comparison> +</documentation> diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeTitleLineWrappingSniff.php b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeTitleLineWrappingSniff.php new file mode 100644 index 0000000000..560b7884c2 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeTitleLineWrappingSniff.php @@ -0,0 +1,12 @@ +<?php +/** + * Test fixture. + * + * @see \PHP_CodeSniffer\Tests\Core\Generators\GeneratorTest + */ + +namespace Fixtures\StandardWithDocs\Sniffs\Content; + +use Fixtures\StandardWithDocs\Sniffs\DummySniff; + +final class CodeTitleLineWrappingSniff extends DummySniff {} diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeTitleWhitespaceSniff.php b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeTitleWhitespaceSniff.php new file mode 100644 index 0000000000..493453a02e --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeTitleWhitespaceSniff.php @@ -0,0 +1,12 @@ +<?php +/** + * Test fixture. + * + * @see \PHP_CodeSniffer\Tests\Core\Generators\GeneratorTest + */ + +namespace Fixtures\StandardWithDocs\Sniffs\Content; + +use Fixtures\StandardWithDocs\Sniffs\DummySniff; + +final class CodeTitleWhitespaceSniff extends DummySniff {} diff --git a/tests/Core/Generators/HTMLTest.php b/tests/Core/Generators/HTMLTest.php index a135c91c62..f11f90b502 100644 --- a/tests/Core/Generators/HTMLTest.php +++ b/tests/Core/Generators/HTMLTest.php @@ -149,6 +149,14 @@ public static function dataDocSpecifics() 'sniffs' => 'StandardWithDocs.Content.StandardLineWrapping', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.html', ], + 'Code Title: line wrapping' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleLineWrapping', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleLineWrapping.html', + ], + 'Code Title: whitespace handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleWhitespace', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.html', + ], ]; }//end dataDocSpecifics() diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php index c93beb4416..9612b36b84 100644 --- a/tests/Core/Generators/MarkdownTest.php +++ b/tests/Core/Generators/MarkdownTest.php @@ -149,6 +149,14 @@ public static function dataDocSpecifics() 'sniffs' => 'StandardWithDocs.Content.StandardLineWrapping', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.md', ], + 'Code Title: line wrapping' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleLineWrapping', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleLineWrapping.md', + ], + 'Code Title: whitespace handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleWhitespace', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.md', + ], ]; }//end dataDocSpecifics() diff --git a/tests/Core/Generators/TextTest.php b/tests/Core/Generators/TextTest.php index d9740bda22..2e0c48035e 100644 --- a/tests/Core/Generators/TextTest.php +++ b/tests/Core/Generators/TextTest.php @@ -149,6 +149,14 @@ public static function dataDocSpecifics() 'sniffs' => 'StandardWithDocs.Content.StandardLineWrapping', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.txt', ], + 'Code Title: line wrapping' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleLineWrapping', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleLineWrapping.txt', + ], + 'Code Title: whitespace handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleWhitespace', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.txt', + ], ]; }//end dataDocSpecifics()