diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php
index 1a4833c56c..b7e209f46a 100644
--- a/src/Generators/HTML.php
+++ b/src/Generators/HTML.php
@@ -383,20 +383,27 @@ protected function printCodeComparisonBlock(DOMNode $node)
*/
protected function getFormattedCodeComparisonBlock(DOMNode $node)
{
- $codeBlocks = $node->getElementsByTagName('code');
+ $codeBlocks = $node->getElementsByTagName('code');
+ $firstCodeElm = $codeBlocks->item(0);
+ $secondCodeElm = $codeBlocks->item(1);
- $firstTitle = trim($codeBlocks->item(0)->getAttribute('title'));
+ if (isset($firstCodeElm, $secondCodeElm) === false) {
+ // Missing at least one code block.
+ return '';
+ }
+
+ $firstTitle = trim($firstCodeElm->getAttribute('title'));
$firstTitle = str_replace(' ', ' ', $firstTitle);
- $first = trim($codeBlocks->item(0)->nodeValue);
+ $first = trim($firstCodeElm->nodeValue);
$first = str_replace('', $first);
$first = str_replace(' ', ' ', $first);
$first = str_replace('', '', $first);
$first = str_replace('', '', $first);
- $secondTitle = trim($codeBlocks->item(1)->getAttribute('title'));
+ $secondTitle = trim($secondCodeElm->getAttribute('title'));
$secondTitle = str_replace(' ', ' ', $secondTitle);
- $second = trim($codeBlocks->item(1)->nodeValue);
+ $second = trim($secondCodeElm->nodeValue);
$second = str_replace('', $second);
$second = str_replace(' ', ' ', $second);
diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php
index c2687e6dcd..d03d06a115 100644
--- a/src/Generators/Markdown.php
+++ b/src/Generators/Markdown.php
@@ -241,18 +241,25 @@ protected function printCodeComparisonBlock(DOMNode $node)
*/
protected function getFormattedCodeComparisonBlock(DOMNode $node)
{
- $codeBlocks = $node->getElementsByTagName('code');
+ $codeBlocks = $node->getElementsByTagName('code');
+ $firstCodeElm = $codeBlocks->item(0);
+ $secondCodeElm = $codeBlocks->item(1);
- $firstTitle = trim($codeBlocks->item(0)->getAttribute('title'));
+ if (isset($firstCodeElm, $secondCodeElm) === false) {
+ // Missing at least one code block.
+ return '';
+ }
+
+ $firstTitle = trim($firstCodeElm->getAttribute('title'));
$firstTitle = str_replace(' ', ' ', $firstTitle);
- $first = trim($codeBlocks->item(0)->nodeValue);
+ $first = trim($firstCodeElm->nodeValue);
$first = str_replace("\n", PHP_EOL.' ', $first);
$first = str_replace('', '', $first);
$first = str_replace('', '', $first);
- $secondTitle = trim($codeBlocks->item(1)->getAttribute('title'));
+ $secondTitle = trim($secondCodeElm->getAttribute('title'));
$secondTitle = str_replace(' ', ' ', $secondTitle);
- $second = trim($codeBlocks->item(1)->nodeValue);
+ $second = trim($secondCodeElm->nodeValue);
$second = str_replace("\n", PHP_EOL.' ', $second);
$second = str_replace('', '', $second);
$second = str_replace('', '', $second);
diff --git a/src/Generators/Text.php b/src/Generators/Text.php
index 28606bdeb4..486e76c7f9 100644
--- a/src/Generators/Text.php
+++ b/src/Generators/Text.php
@@ -198,9 +198,17 @@ protected function printCodeComparisonBlock(DOMNode $node)
*/
protected function getFormattedCodeComparisonBlock(DOMNode $node)
{
- $codeBlocks = $node->getElementsByTagName('code');
- $first = trim($codeBlocks->item(0)->nodeValue);
- $firstTitle = trim($codeBlocks->item(0)->getAttribute('title'));
+ $codeBlocks = $node->getElementsByTagName('code');
+ $firstCodeElm = $codeBlocks->item(0);
+ $secondCodeElm = $codeBlocks->item(1);
+
+ if (isset($firstCodeElm, $secondCodeElm) === false) {
+ // Missing at least one code block.
+ return '';
+ }
+
+ $first = trim($firstCodeElm->nodeValue);
+ $firstTitle = trim($firstCodeElm->getAttribute('title'));
$firstTitleLines = [];
$tempTitle = '';
@@ -234,8 +242,8 @@ protected function getFormattedCodeComparisonBlock(DOMNode $node)
$first = str_replace('', '', $first);
$firstLines = explode("\n", $first);
- $second = trim($codeBlocks->item(1)->nodeValue);
- $secondTitle = trim($codeBlocks->item(1)->getAttribute('title'));
+ $second = trim($secondCodeElm->nodeValue);
+ $secondTitle = trim($secondCodeElm->getAttribute('title'));
$secondTitleLines = [];
$tempTitle = '';
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.html b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.html
new file mode 100644
index 0000000000..6ff1711cea
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.html
@@ -0,0 +1,88 @@
+
+
+ GeneratorTest Coding Standards
+
+
+
+ GeneratorTest Coding Standards
+
+ Code Comparison, mismatched code blocks
+ This doc has two code elements, one only has a title, one has actual code. Unbalanced
+
+
+ Code title |
+ |
+
+
+ |
+ $a = 'Example code'; |
+
+
+
+
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.md b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.md
new file mode 100644
index 0000000000..bbd1f312a7
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.md
@@ -0,0 +1,25 @@
+# GeneratorTest Coding Standard
+
+## Code Comparison, mismatched code blocks
+
+This doc has two code elements, one only has a title, one has actual code. Unbalanced
+
+
+ Code title |
+ |
+
+
+
+
+
+
+ |
+
+
+ $a = 'Example code';
+
+ |
+
+
+
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.txt b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.txt
new file mode 100644
index 0000000000..85b3f31a08
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.txt
@@ -0,0 +1,13 @@
+
+--------------------------------------------------------------------------
+| GENERATORTEST CODING STANDARD: CODE COMPARISON, MISMATCHED CODE BLOCKS |
+--------------------------------------------------------------------------
+
+This doc has two code elements, one only has a title, one has actual code. Unbalanced
+
+----------------------------------------- CODE COMPARISON ------------------------------------------
+| Code title | |
+----------------------------------------------------------------------------------------------------
+| | $a = 'Example code'; |
+----------------------------------------------------------------------------------------------------
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.html b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.html
new file mode 100644
index 0000000000..c699cb7d20
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.html
@@ -0,0 +1,78 @@
+
+
+ GeneratorTest Coding Standards
+
+
+
+ GeneratorTest Coding Standards
+
+ Code Comparison, missing code element
+ This is a standard block.
+
+
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.md b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.md
new file mode 100644
index 0000000000..4cd4b41b47
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.md
@@ -0,0 +1,7 @@
+# GeneratorTest Coding Standard
+
+## Code Comparison, missing code element
+
+This is a standard block.
+
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.txt b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.txt
new file mode 100644
index 0000000000..0c3c6d13d8
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.txt
@@ -0,0 +1,7 @@
+
+------------------------------------------------------------------------
+| GENERATORTEST CODING STANDARD: CODE COMPARISON, MISSING CODE ELEMENT |
+------------------------------------------------------------------------
+
+This is a standard block.
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.html b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.html
new file mode 100644
index 0000000000..c1db1a7bb7
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.html
@@ -0,0 +1,88 @@
+
+
+ GeneratorTest Coding Standards
+
+
+
+ GeneratorTest Coding Standards
+
+ Code Comparison, no code
+ This is a standard block.
+
+
+ Valid: no code. |
+ Invalid: no code. |
+
+
+ |
+ |
+
+
+
+
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.md b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.md
new file mode 100644
index 0000000000..b64dbf01f2
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.md
@@ -0,0 +1,25 @@
+# GeneratorTest Coding Standard
+
+## Code Comparison, no code
+
+This is a standard block.
+
+
+ Valid: no code. |
+ Invalid: no code. |
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.txt b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.txt
new file mode 100644
index 0000000000..a99fdbc6c3
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.txt
@@ -0,0 +1,13 @@
+
+-----------------------------------------------------------
+| GENERATORTEST CODING STANDARD: CODE COMPARISON, NO CODE |
+-----------------------------------------------------------
+
+This is a standard block.
+
+----------------------------------------- CODE COMPARISON ------------------------------------------
+| Valid: no code. | Invalid: no code. |
+----------------------------------------------------------------------------------------------------
+| | |
+----------------------------------------------------------------------------------------------------
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.html b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.html
new file mode 100644
index 0000000000..02b031224b
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.html
@@ -0,0 +1,78 @@
+
+
+ GeneratorTest Coding Standards
+
+
+
+ GeneratorTest Coding Standards
+
+ Code Comparison, no content
+ This is a standard block.
+
+
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.md b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.md
new file mode 100644
index 0000000000..1cea477ff1
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.md
@@ -0,0 +1,7 @@
+# GeneratorTest Coding Standard
+
+## Code Comparison, no content
+
+This is a standard block.
+
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.txt b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.txt
new file mode 100644
index 0000000000..0227cdc829
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.txt
@@ -0,0 +1,7 @@
+
+--------------------------------------------------------------
+| GENERATORTEST CODING STANDARD: CODE COMPARISON, NO CONTENT |
+--------------------------------------------------------------
+
+This is a standard block.
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.html b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.html
new file mode 100644
index 0000000000..8343920211
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.html
@@ -0,0 +1,88 @@
+
+
+ GeneratorTest Coding Standards
+
+
+
+ GeneratorTest Coding Standards
+
+ Code Comparison, one empty code element
+ This doc has two code elements, but only one of them has a title and actual code.
+
+
+ Code title |
+ |
+
+
+ $a = 'Example code'; |
+ |
+
+
+
+
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.md b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.md
new file mode 100644
index 0000000000..829f136350
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.md
@@ -0,0 +1,25 @@
+# GeneratorTest Coding Standard
+
+## Code Comparison, one empty code element
+
+This doc has two code elements, but only one of them has a title and actual code.
+
+
+ Code title |
+ |
+
+
+
+
+ $a = 'Example code';
+
+ |
+
+
+
+
+ |
+
+
+
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.txt b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.txt
new file mode 100644
index 0000000000..7e9370595f
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.txt
@@ -0,0 +1,13 @@
+
+--------------------------------------------------------------------------
+| GENERATORTEST CODING STANDARD: CODE COMPARISON, ONE EMPTY CODE ELEMENT |
+--------------------------------------------------------------------------
+
+This doc has two code elements, but only one of them has a title and actual code.
+
+----------------------------------------- CODE COMPARISON ------------------------------------------
+| Code title | |
+----------------------------------------------------------------------------------------------------
+| $a = 'Example code'; | |
+----------------------------------------------------------------------------------------------------
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.html b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.html
new file mode 100644
index 0000000000..f1c8f75bad
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.html
@@ -0,0 +1,88 @@
+
+
+ GeneratorTest Coding Standards
+
+
+
+ GeneratorTest Coding Standards
+
+ Code Comparison, two empty code elements
+ This doc has two code elements, but neither of them contain any information.
+
+
+
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.md b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.md
new file mode 100644
index 0000000000..424c38af72
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.md
@@ -0,0 +1,25 @@
+# GeneratorTest Coding Standard
+
+## Code Comparison, two empty code elements
+
+This doc has two code elements, but neither of them contain any information.
+
+
+ |
+ |
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.txt b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.txt
new file mode 100644
index 0000000000..4508467076
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.txt
@@ -0,0 +1,13 @@
+
+---------------------------------------------------------------------------
+| GENERATORTEST CODING STANDARD: CODE COMPARISON, TWO EMPTY CODE ELEMENTS |
+---------------------------------------------------------------------------
+
+This doc has two code elements, but neither of them contain any information.
+
+----------------------------------------- CODE COMPARISON ------------------------------------------
+| | |
+----------------------------------------------------------------------------------------------------
+| | |
+----------------------------------------------------------------------------------------------------
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleEmpty.html b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleEmpty.html
new file mode 100644
index 0000000000..ae9fb7aa68
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleEmpty.html
@@ -0,0 +1,88 @@
+
+
+ GeneratorTest Coding Standards
+
+
+
+ GeneratorTest Coding Standards
+
+ Code Title, empty
+ This is a standard block.
+
+
+ |
+ |
+
+
+ // Dummy. |
+ // Dummy. |
+
+
+
+
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleEmpty.md b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleEmpty.md
new file mode 100644
index 0000000000..312c65d486
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleEmpty.md
@@ -0,0 +1,25 @@
+# GeneratorTest Coding Standard
+
+## Code Title, empty
+
+This is a standard block.
+
+
+ |
+ |
+
+
+
+
+ // Dummy.
+
+ |
+
+
+ // Dummy.
+
+ |
+
+
+
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleEmpty.txt b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleEmpty.txt
new file mode 100644
index 0000000000..904a1485ea
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleEmpty.txt
@@ -0,0 +1,13 @@
+
+----------------------------------------------------
+| GENERATORTEST CODING STANDARD: CODE TITLE, EMPTY |
+----------------------------------------------------
+
+This is a standard block.
+
+----------------------------------------- CODE COMPARISON ------------------------------------------
+| | |
+----------------------------------------------------------------------------------------------------
+| // Dummy. | // Dummy. |
+----------------------------------------------------------------------------------------------------
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleMissing.html b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleMissing.html
new file mode 100644
index 0000000000..9121273f3d
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleMissing.html
@@ -0,0 +1,88 @@
+
+
+ GeneratorTest Coding Standards
+
+
+
+ GeneratorTest Coding Standards
+
+ Code Title, missing
+ This is a standard block.
+
+
+ |
+ |
+
+
+ // Dummy. |
+ // Dummy. |
+
+
+
+
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleMissing.md b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleMissing.md
new file mode 100644
index 0000000000..ddd6f6b7a4
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleMissing.md
@@ -0,0 +1,25 @@
+# GeneratorTest Coding Standard
+
+## Code Title, missing
+
+This is a standard block.
+
+
+ |
+ |
+
+
+
+
+ // Dummy.
+
+ |
+
+
+ // Dummy.
+
+ |
+
+
+
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleMissing.txt b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleMissing.txt
new file mode 100644
index 0000000000..95adef296c
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidCodeTitleMissing.txt
@@ -0,0 +1,13 @@
+
+------------------------------------------------------
+| GENERATORTEST CODING STANDARD: CODE TITLE, MISSING |
+------------------------------------------------------
+
+This is a standard block.
+
+----------------------------------------- CODE COMPARISON ------------------------------------------
+| | |
+----------------------------------------------------------------------------------------------------
+| // Dummy. | // Dummy. |
+----------------------------------------------------------------------------------------------------
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.html b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.html
new file mode 100644
index 0000000000..c3c92a8a37
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.html
@@ -0,0 +1,88 @@
+
+
+ GeneratorTest Coding Standards
+
+
+
+ GeneratorTest Coding Standards
+
+
+ The above "documentation" element has an empty title attribute.
+
+
+ Valid: Lorem ipsum dolor sit amet. |
+ Invalid: Maecenas non rutrum dolor. |
+
+
+ class Code {} |
+ class Comparison {} |
+
+
+
+
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.md b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.md
new file mode 100644
index 0000000000..d36609c0f6
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.md
@@ -0,0 +1,25 @@
+# GeneratorTest Coding Standard
+
+##
+
+The above "documentation" element has an empty title attribute.
+
+
+ Valid: Lorem ipsum dolor sit amet. |
+ Invalid: Maecenas non rutrum dolor. |
+
+
+
+
+ class Code {}
+
+ |
+
+
+ class Comparison {}
+
+ |
+
+
+
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.txt b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.txt
new file mode 100644
index 0000000000..8fb0182be5
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.txt
@@ -0,0 +1,13 @@
+
+-----------------------------------
+| GENERATORTEST CODING STANDARD: |
+-----------------------------------
+
+The above "documentation" element has an empty title attribute.
+
+----------------------------------------- CODE COMPARISON ------------------------------------------
+| Valid: Lorem ipsum dolor sit amet. | Invalid: Maecenas non rutrum dolor. |
+----------------------------------------------------------------------------------------------------
+| class Code {} | class Comparison {} |
+----------------------------------------------------------------------------------------------------
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.html b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.html
new file mode 100644
index 0000000000..d0af2bea8b
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.html
@@ -0,0 +1,88 @@
+
+
+ GeneratorTest Coding Standards
+
+
+
+ GeneratorTest Coding Standards
+
+
+ The above "documentation" element is missing the title attribute.
+
+
+ Valid: Lorem ipsum dolor sit amet. |
+ Invalid: Maecenas non rutrum dolor. |
+
+
+ class Code {} |
+ class Comparison {} |
+
+
+
+
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.md b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.md
new file mode 100644
index 0000000000..5dc91a6479
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.md
@@ -0,0 +1,25 @@
+# GeneratorTest Coding Standard
+
+##
+
+The above "documentation" element is missing the title attribute.
+
+
+ Valid: Lorem ipsum dolor sit amet. |
+ Invalid: Maecenas non rutrum dolor. |
+
+
+
+
+ class Code {}
+
+ |
+
+
+ class Comparison {}
+
+ |
+
+
+
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.txt b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.txt
new file mode 100644
index 0000000000..85ef693575
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.txt
@@ -0,0 +1,13 @@
+
+-----------------------------------
+| GENERATORTEST CODING STANDARD: |
+-----------------------------------
+
+The above "documentation" element is missing the title attribute.
+
+----------------------------------------- CODE COMPARISON ------------------------------------------
+| Valid: Lorem ipsum dolor sit amet. | Invalid: Maecenas non rutrum dolor. |
+----------------------------------------------------------------------------------------------------
+| class Code {} | class Comparison {} |
+----------------------------------------------------------------------------------------------------
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidStandardNoContent.html b/tests/Core/Generators/Expectations/ExpectedOutputInvalidStandardNoContent.html
new file mode 100644
index 0000000000..b5fbf05b9c
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidStandardNoContent.html
@@ -0,0 +1,88 @@
+
+
+ GeneratorTest Coding Standards
+
+
+
+ GeneratorTest Coding Standards
+
+ Standard Element, no content
+
+
+
+ Valid: Lorem ipsum dolor sit amet. |
+ Invalid: Maecenas non rutrum dolor. |
+
+
+ class Code {} |
+ class Comparison {} |
+
+
+
+
+
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidStandardNoContent.md b/tests/Core/Generators/Expectations/ExpectedOutputInvalidStandardNoContent.md
new file mode 100644
index 0000000000..8a97b98604
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidStandardNoContent.md
@@ -0,0 +1,25 @@
+# GeneratorTest Coding Standard
+
+## Standard Element, no content
+
+
+
+
+ Valid: Lorem ipsum dolor sit amet. |
+ Invalid: Maecenas non rutrum dolor. |
+
+
+
+
+ class Code {}
+
+ |
+
+
+ class Comparison {}
+
+ |
+
+
+
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
diff --git a/tests/Core/Generators/Expectations/ExpectedOutputInvalidStandardNoContent.txt b/tests/Core/Generators/Expectations/ExpectedOutputInvalidStandardNoContent.txt
new file mode 100644
index 0000000000..cb65d4f4c6
--- /dev/null
+++ b/tests/Core/Generators/Expectations/ExpectedOutputInvalidStandardNoContent.txt
@@ -0,0 +1,13 @@
+
+---------------------------------------------------------------
+| GENERATORTEST CODING STANDARD: STANDARD ELEMENT, NO CONTENT |
+---------------------------------------------------------------
+
+
+
+----------------------------------------- CODE COMPARISON ------------------------------------------
+| Valid: Lorem ipsum dolor sit amet. | Invalid: Maecenas non rutrum dolor. |
+----------------------------------------------------------------------------------------------------
+| class Code {} | class Comparison {} |
+----------------------------------------------------------------------------------------------------
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonMismatchedCodeElmsStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonMismatchedCodeElmsStandard.xml
new file mode 100644
index 0000000000..d0cfff4110
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonMismatchedCodeElmsStandard.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonMissingCodeElmStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonMissingCodeElmStandard.xml
new file mode 100644
index 0000000000..999901ebbd
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonMissingCodeElmStandard.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonNoCodeStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonNoCodeStandard.xml
new file mode 100644
index 0000000000..54b50ff8db
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonNoCodeStandard.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonNoContentStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonNoContentStandard.xml
new file mode 100644
index 0000000000..0dfb12fa0d
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonNoContentStandard.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonOneEmptyCodeElmStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonOneEmptyCodeElmStandard.xml
new file mode 100644
index 0000000000..b40674413f
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonOneEmptyCodeElmStandard.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonTwoEmptyCodeElmsStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonTwoEmptyCodeElmsStandard.xml
new file mode 100644
index 0000000000..e6cb071451
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeComparisonTwoEmptyCodeElmsStandard.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeTitleEmptyStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeTitleEmptyStandard.xml
new file mode 100644
index 0000000000..034bdf2fd8
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeTitleEmptyStandard.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeTitleMissingStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeTitleMissingStandard.xml
new file mode 100644
index 0000000000..89599dd2be
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/CodeTitleMissingStandard.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/DocumentationTitleEmptyStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/DocumentationTitleEmptyStandard.xml
new file mode 100644
index 0000000000..c3ab071d13
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/DocumentationTitleEmptyStandard.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ class Code {}
+ ]]>
+
+
+ class Comparison {}
+ ]]>
+
+
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/DocumentationTitleMissingStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/DocumentationTitleMissingStandard.xml
new file mode 100644
index 0000000000..974071d9fb
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/DocumentationTitleMissingStandard.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ class Code {}
+ ]]>
+
+
+ class Comparison {}
+ ]]>
+
+
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/StandardNoContentStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/StandardNoContentStandard.xml
new file mode 100644
index 0000000000..e6934706a2
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Invalid/StandardNoContentStandard.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ class Code {}
+ ]]>
+
+
+ class Comparison {}
+ ]]>
+
+
+
diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Invalid/CodeComparisonMismatchedCodeElmsSniff.php b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Invalid/CodeComparisonMismatchedCodeElmsSniff.php
new file mode 100644
index 0000000000..91a50f4ce3
--- /dev/null
+++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Invalid/CodeComparisonMismatchedCodeElmsSniff.php
@@ -0,0 +1,12 @@
+ [
+ 'Documentation title: case' => [
'sniffs' => 'StandardWithDocs.Content.DocumentationTitleCase',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleCase.html',
],
- 'Documentation title: length' => [
+ 'Documentation title: length' => [
'sniffs' => 'StandardWithDocs.Content.DocumentationTitleLength',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleLength.html',
],
- 'Standard Element: blank line handling' => [
+ 'Standard Element: blank line handling' => [
'sniffs' => 'StandardWithDocs.Content.StandardBlankLines',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardBlankLines.html',
],
- 'Standard Element: encoding of special characters' => [
+ 'Standard Element: encoding of special characters' => [
'sniffs' => 'StandardWithDocs.Content.StandardEncoding',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardEncoding.html',
],
- 'Standard Element: indent handling' => [
+ 'Standard Element: indent handling' => [
'sniffs' => 'StandardWithDocs.Content.StandardIndent',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardIndent.html',
],
- 'Standard Element: line wrapping' => [
+ 'Standard Element: line wrapping' => [
'sniffs' => 'StandardWithDocs.Content.StandardLineWrapping',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.html',
],
- 'Code Title: line wrapping' => [
+ 'Code Title: line wrapping' => [
'sniffs' => 'StandardWithDocs.Content.CodeTitleLineWrapping',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleLineWrapping.html',
],
- 'Code Title: whitespace handling' => [
+ 'Code Title: whitespace handling' => [
'sniffs' => 'StandardWithDocs.Content.CodeTitleWhitespace',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.html',
],
- 'Code Comparison: blank line handling' => [
+ 'Code Comparison: blank line handling' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlankLines',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlankLines.html',
],
- 'Code Comparison: different block lengths' => [
+ 'Code Comparison: different block lengths' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlockLength',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlockLength.html',
],
- 'Code Comparison: encoding of special characters' => [
+ 'Code Comparison: encoding of special characters' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonEncoding',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonEncoding.html',
],
- 'Code Comparison: line length handling' => [
+ 'Code Comparison: line length handling' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonLineLength',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonLineLength.html',
],
- 'Unsupported: element at the wrong level' => [
+ 'Unsupported: element at the wrong level' => [
'sniffs' => 'StandardWithDocs.Unsupported.ElementAtWrongLevel',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt',
],
- 'Unsupported: one correct elm, one at wrong level' => [
+ 'Unsupported: one correct elm, one at wrong level' => [
'sniffs' => 'StandardWithDocs.Unsupported.OneElmAtWrongLevel',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.html',
],
- 'Unsupported: superfluous code element' => [
+ 'Unsupported: superfluous code element' => [
'sniffs' => 'StandardWithDocs.Unsupported.SuperfluousCodeElement',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.html',
],
- 'Unsupported: unknown element' => [
+ 'Unsupported: unknown element' => [
'sniffs' => 'StandardWithDocs.Unsupported.UnknownElement',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt',
],
+ 'Invalid: code comparison mismatched code elms' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonMismatchedCodeElms',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.html',
+ ],
+ 'Invalid: code comparison only has one code elm' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonMissingCodeElm',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.html',
+ ],
+ 'Invalid: code elements have no content' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonNoCode',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.html',
+ ],
+ 'Invalid: code comparison element has no content' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonNoContent',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.html',
+ ],
+ 'Invalid: code comparison two code elms, one empty' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonOneEmptyCodeElm',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.html',
+ ],
+ 'Invalid: code comparison two empty code elms' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonTwoEmptyCodeElms',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.html',
+ ],
+ 'Invalid: code title attributes are empty' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeTitleEmpty',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeTitleEmpty.html',
+ ],
+ 'Invalid: code title attributes missing' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeTitleMissing',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeTitleMissing.html',
+ ],
+ 'Invalid: documentation title attribute is empty' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.DocumentationTitleEmpty',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.html',
+ ],
+ 'Invalid: documentation title attribute missing' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.DocumentationTitleMissing',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.html',
+ ],
+ 'Invalid: standard element has no content' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.StandardNoContent',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidStandardNoContent.html',
+ ],
];
}//end dataDocSpecifics()
diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php
index edc9db8c31..1bcddbebcc 100644
--- a/tests/Core/Generators/MarkdownTest.php
+++ b/tests/Core/Generators/MarkdownTest.php
@@ -125,70 +125,114 @@ public function testDocSpecifics($sniffs, $pathToExpected)
public static function dataDocSpecifics()
{
return [
- 'Documentation title: case' => [
+ 'Documentation title: case' => [
'sniffs' => 'StandardWithDocs.Content.DocumentationTitleCase',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleCase.md',
],
- 'Documentation title: length' => [
+ 'Documentation title: length' => [
'sniffs' => 'StandardWithDocs.Content.DocumentationTitleLength',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleLength.md',
],
- 'Standard Element: blank line handling' => [
+ 'Standard Element: blank line handling' => [
'sniffs' => 'StandardWithDocs.Content.StandardBlankLines',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardBlankLines.md',
],
- 'Standard Element: encoding of special characters' => [
+ 'Standard Element: encoding of special characters' => [
'sniffs' => 'StandardWithDocs.Content.StandardEncoding',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardEncoding.md',
],
- 'Standard Element: indent handling' => [
+ 'Standard Element: indent handling' => [
'sniffs' => 'StandardWithDocs.Content.StandardIndent',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardIndent.md',
],
- 'Standard Element: line wrapping' => [
+ 'Standard Element: line wrapping' => [
'sniffs' => 'StandardWithDocs.Content.StandardLineWrapping',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.md',
],
- 'Code Title: line wrapping' => [
+ 'Code Title: line wrapping' => [
'sniffs' => 'StandardWithDocs.Content.CodeTitleLineWrapping',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleLineWrapping.md',
],
- 'Code Title: whitespace handling' => [
+ 'Code Title: whitespace handling' => [
'sniffs' => 'StandardWithDocs.Content.CodeTitleWhitespace',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.md',
],
- 'Code Comparison: blank line handling' => [
+ 'Code Comparison: blank line handling' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlankLines',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlankLines.md',
],
- 'Code Comparison: different block lengths' => [
+ 'Code Comparison: different block lengths' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlockLength',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlockLength.md',
],
- 'Code Comparison: encoding of special characters' => [
+ 'Code Comparison: encoding of special characters' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonEncoding',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonEncoding.md',
],
- 'Code Comparison: line length handling' => [
+ 'Code Comparison: line length handling' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonLineLength',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonLineLength.md',
],
- 'Unsupported: element at the wrong level' => [
+ 'Unsupported: element at the wrong level' => [
'sniffs' => 'StandardWithDocs.Unsupported.ElementAtWrongLevel',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt',
],
- 'Unsupported: one correct elm, one at wrong level' => [
+ 'Unsupported: one correct elm, one at wrong level' => [
'sniffs' => 'StandardWithDocs.Unsupported.OneElmAtWrongLevel',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.md',
],
- 'Unsupported: superfluous code element' => [
+ 'Unsupported: superfluous code element' => [
'sniffs' => 'StandardWithDocs.Unsupported.SuperfluousCodeElement',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.md',
],
- 'Unsupported: unknown element' => [
+ 'Unsupported: unknown element' => [
'sniffs' => 'StandardWithDocs.Unsupported.UnknownElement',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt',
],
+ 'Invalid: code comparison mismatched code elms' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonMismatchedCodeElms',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.md',
+ ],
+ 'Invalid: code comparison only has one code elm' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonMissingCodeElm',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.md',
+ ],
+ 'Invalid: code elements have no content' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonNoCode',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.md',
+ ],
+ 'Invalid: code comparison element has no content' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonNoContent',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.md',
+ ],
+ 'Invalid: code comparison two code elms, one empty' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonOneEmptyCodeElm',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.md',
+ ],
+ 'Invalid: code comparison two empty code elms' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonTwoEmptyCodeElms',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.md',
+ ],
+ 'Invalid: code title attributes are empty' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeTitleEmpty',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeTitleEmpty.md',
+ ],
+ 'Invalid: code title attributes missing' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeTitleMissing',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeTitleMissing.md',
+ ],
+ 'Invalid: documentation title attribute is empty' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.DocumentationTitleEmpty',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.md',
+ ],
+ 'Invalid: documentation title attribute missing' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.DocumentationTitleMissing',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.md',
+ ],
+ 'Invalid: standard element has no content' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.StandardNoContent',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidStandardNoContent.md',
+ ],
];
}//end dataDocSpecifics()
diff --git a/tests/Core/Generators/TextTest.php b/tests/Core/Generators/TextTest.php
index 5b157bd774..33d6c7e1db 100644
--- a/tests/Core/Generators/TextTest.php
+++ b/tests/Core/Generators/TextTest.php
@@ -125,70 +125,114 @@ public function testDocSpecifics($sniffs, $pathToExpected)
public static function dataDocSpecifics()
{
return [
- 'Documentation title: case' => [
+ 'Documentation title: case' => [
'sniffs' => 'StandardWithDocs.Content.DocumentationTitleCase',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleCase.txt',
],
- 'Documentation title: length' => [
+ 'Documentation title: length' => [
'sniffs' => 'StandardWithDocs.Content.DocumentationTitleLength',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleLength.txt',
],
- 'Standard Element: blank line handling' => [
+ 'Standard Element: blank line handling' => [
'sniffs' => 'StandardWithDocs.Content.StandardBlankLines',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardBlankLines.txt',
],
- 'Standard Element: encoding of special characters' => [
+ 'Standard Element: encoding of special characters' => [
'sniffs' => 'StandardWithDocs.Content.StandardEncoding',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardEncoding.txt',
],
- 'Standard Element: indent handling' => [
+ 'Standard Element: indent handling' => [
'sniffs' => 'StandardWithDocs.Content.StandardIndent',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardIndent.txt',
],
- 'Standard Element: line wrapping' => [
+ 'Standard Element: line wrapping' => [
'sniffs' => 'StandardWithDocs.Content.StandardLineWrapping',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.txt',
],
- 'Code Title: line wrapping' => [
+ 'Code Title: line wrapping' => [
'sniffs' => 'StandardWithDocs.Content.CodeTitleLineWrapping',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleLineWrapping.txt',
],
- 'Code Title: whitespace handling' => [
+ 'Code Title: whitespace handling' => [
'sniffs' => 'StandardWithDocs.Content.CodeTitleWhitespace',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.txt',
],
- 'Code Comparison: blank line handling' => [
+ 'Code Comparison: blank line handling' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlankLines',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlankLines.txt',
],
- 'Code Comparison: different block lengths' => [
+ 'Code Comparison: different block lengths' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlockLength',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlockLength.txt',
],
- 'Code Comparison: encoding of special characters' => [
+ 'Code Comparison: encoding of special characters' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonEncoding',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonEncoding.txt',
],
- 'Code Comparison: line length handling' => [
+ 'Code Comparison: line length handling' => [
'sniffs' => 'StandardWithDocs.Content.CodeComparisonLineLength',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonLineLength.txt',
],
- 'Unsupported: element at the wrong level' => [
+ 'Unsupported: element at the wrong level' => [
'sniffs' => 'StandardWithDocs.Unsupported.ElementAtWrongLevel',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt',
],
- 'Unsupported: one correct elm, one at wrong level' => [
+ 'Unsupported: one correct elm, one at wrong level' => [
'sniffs' => 'StandardWithDocs.Unsupported.OneElmAtWrongLevel',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.txt',
],
- 'Unsupported: superfluous code element' => [
+ 'Unsupported: superfluous code element' => [
'sniffs' => 'StandardWithDocs.Unsupported.SuperfluousCodeElement',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.txt',
],
- 'Unsupported: unknown element' => [
+ 'Unsupported: unknown element' => [
'sniffs' => 'StandardWithDocs.Unsupported.UnknownElement',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt',
],
+ 'Invalid: code comparison mismatched code elms' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonMismatchedCodeElms',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonMismatchedCodeElms.txt',
+ ],
+ 'Invalid: code comparison only has one code elm' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonMissingCodeElm',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonMissingCodeElm.txt',
+ ],
+ 'Invalid: code elements have no content' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonNoCode',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonNoCode.txt',
+ ],
+ 'Invalid: code comparison element has no content' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonNoContent',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonNoContent.txt',
+ ],
+ 'Invalid: code comparison two code elms, one empty' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonOneEmptyCodeElm',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonOneEmptyCodeElm.txt',
+ ],
+ 'Invalid: code comparison two empty code elms' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeComparisonTwoEmptyCodeElms',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeComparisonTwoEmptyCodeElms.txt',
+ ],
+ 'Invalid: code title attributes are empty' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeTitleEmpty',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeTitleEmpty.txt',
+ ],
+ 'Invalid: code title attributes missing' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.CodeTitleMissing',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidCodeTitleMissing.txt',
+ ],
+ 'Invalid: documentation title attribute is empty' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.DocumentationTitleEmpty',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidDocumentationTitleEmpty.txt',
+ ],
+ 'Invalid: documentation title attribute missing' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.DocumentationTitleMissing',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidDocumentationTitleMissing.txt',
+ ],
+ 'Invalid: standard element has no content' => [
+ 'sniffs' => 'StandardWithDocs.Invalid.StandardNoContent',
+ 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputInvalidStandardNoContent.txt',
+ ],
];
}//end dataDocSpecifics()