-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #719 from PHPCSStandards/feature/generators-add-te…
…sts-code-sample Generators: add tests for handling code samples
- Loading branch information
Showing
23 changed files
with
836 additions
and
0 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<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-Comparison,-blank-lines" /> | ||
<h2>Code Comparison, blank lines</h2> | ||
<p class="text">This is a standard block.</p> | ||
<table class="code-comparison"> | ||
<tr> | ||
<td class="code-comparison-title">Valid: Checking handling of blank lines.</td> | ||
<td class="code-comparison-title">Invalid: Checking handling of blank lines.</td> | ||
</tr> | ||
<tr> | ||
<td class="code-comparison-code">// First line of the code sample is</br>// deliberately empty.</br></br>// We also have a blank line in the middle.</br></br>// And a blank line at the end.</td> | ||
<td class="code-comparison-code">// First line of the code sample is</br>// deliberately empty.</br></br>// We also have a blank line in the middle.</br></br>// And a blank line at the end.</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> |
34 changes: 34 additions & 0 deletions
34
tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# GeneratorTest Coding Standard | ||
|
||
## Code Comparison, blank lines | ||
This is a standard block. | ||
<table> | ||
<tr> | ||
<th>Valid: Checking handling of blank lines.</th> | ||
<th>Invalid: Checking handling of blank lines.</th> | ||
</tr> | ||
<tr> | ||
<td> | ||
|
||
// First line of the code sample is | ||
// deliberately empty. | ||
|
||
// We also have a blank line in the middle. | ||
|
||
// And a blank line at the end. | ||
|
||
</td> | ||
<td> | ||
|
||
// First line of the code sample is | ||
// deliberately empty. | ||
|
||
// We also have a blank line in the middle. | ||
|
||
// And a blank line at the end. | ||
|
||
</td> | ||
</tr> | ||
</table> | ||
|
||
Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) |
18 changes: 18 additions & 0 deletions
18
tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
--------------------------------------------------------------- | ||
| GENERATORTEST CODING STANDARD: CODE COMPARISON, BLANK LINES | | ||
--------------------------------------------------------------- | ||
|
||
This is a standard block. | ||
|
||
----------------------------------------- CODE COMPARISON ------------------------------------------ | ||
| Valid: Checking handling of blank lines. | Invalid: Checking handling of blank lines. | | ||
---------------------------------------------------------------------------------------------------- | ||
| // First line of the code sample is | // First line of the code sample is | | ||
| // deliberately empty. | // deliberately empty. | | ||
| | | | ||
| // We also have a blank line in the middle. | // We also have a blank line in the middle. | | ||
| | | | ||
| // And a blank line at the end. | // And a blank line at the end. | | ||
---------------------------------------------------------------------------------------------------- | ||
|
98 changes: 98 additions & 0 deletions
98
tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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-Comparison,-block-length" /> | ||
<h2>Code Comparison, block length</h2> | ||
<p class="text">This is a standard block.</p> | ||
<table class="code-comparison"> | ||
<tr> | ||
<td class="code-comparison-title">Valid: code sample A has more lines than B.</td> | ||
<td class="code-comparison-title">Invalid: shorter.</td> | ||
</tr> | ||
<tr> | ||
<td class="code-comparison-code">// This code sample has more lines</br>// than the "invalid" one.</br><span class="code-comparison-highlight">$one</span> = 10;</td> | ||
<td class="code-comparison-code"><span class="code-comparison-highlight">$a</span> = 10;</td> | ||
</tr> | ||
</table> | ||
<table class="code-comparison"> | ||
<tr> | ||
<td class="code-comparison-title">Valid: shorter.</td> | ||
<td class="code-comparison-title">Invalid: code sample B has more lines than A.</td> | ||
</tr> | ||
<tr> | ||
<td class="code-comparison-code"><span class="code-comparison-highlight">echo</span> $foo;</td> | ||
<td class="code-comparison-code">// This code sample has more lines</br>// than the "valid" one.</br><span class="code-comparison-highlight">print</span> $foo;</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> |
46 changes: 46 additions & 0 deletions
46
tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# GeneratorTest Coding Standard | ||
|
||
## Code Comparison, block length | ||
This is a standard block. | ||
<table> | ||
<tr> | ||
<th>Valid: code sample A has more lines than B.</th> | ||
<th>Invalid: shorter.</th> | ||
</tr> | ||
<tr> | ||
<td> | ||
|
||
// This code sample has more lines | ||
// than the "invalid" one. | ||
$one = 10; | ||
|
||
</td> | ||
<td> | ||
|
||
$a = 10; | ||
|
||
</td> | ||
</tr> | ||
</table> | ||
<table> | ||
<tr> | ||
<th>Valid: shorter.</th> | ||
<th>Invalid: code sample B has more lines than A.</th> | ||
</tr> | ||
<tr> | ||
<td> | ||
|
||
echo $foo; | ||
|
||
</td> | ||
<td> | ||
|
||
// This code sample has more lines | ||
// than the "valid" one. | ||
print $foo; | ||
|
||
</td> | ||
</tr> | ||
</table> | ||
|
||
Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) |
23 changes: 23 additions & 0 deletions
23
tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
---------------------------------------------------------------- | ||
| GENERATORTEST CODING STANDARD: CODE COMPARISON, BLOCK LENGTH | | ||
---------------------------------------------------------------- | ||
|
||
This is a standard block. | ||
|
||
----------------------------------------- CODE COMPARISON ------------------------------------------ | ||
| Valid: code sample A has more lines than B. | Invalid: shorter. | | ||
---------------------------------------------------------------------------------------------------- | ||
| // This code sample has more lines | $a = 10; | | ||
| // than the "invalid" one. | | | ||
| $one = 10; | | | ||
---------------------------------------------------------------------------------------------------- | ||
|
||
----------------------------------------- CODE COMPARISON ------------------------------------------ | ||
| Valid: shorter. | Invalid: code sample B has more lines than A. | | ||
---------------------------------------------------------------------------------------------------- | ||
| echo $foo; | // This code sample has more lines | | ||
| | // than the "valid" one. | | ||
| | print $foo; | | ||
---------------------------------------------------------------------------------------------------- | ||
|
Oops, something went wrong.