Skip to content

Commit 87d5030

Browse files
committed
Generators: add tests for handling code samples
This adds dedicated tests for specific issues which can be encountered with the contents of `<code>` elements. This initial set of tests for this documents the current behaviour. This behaviour may not always be the desired behaviour, in which case, this will be fixed in follow-up commits.
1 parent 9819deb commit 87d5030

23 files changed

+836
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<html>
2+
<head>
3+
<title>GeneratorTest Coding Standards</title>
4+
<style>
5+
body {
6+
background-color: #FFFFFF;
7+
font-size: 14px;
8+
font-family: Arial, Helvetica, sans-serif;
9+
color: #000000;
10+
}
11+
12+
h1 {
13+
color: #666666;
14+
font-size: 20px;
15+
font-weight: bold;
16+
margin-top: 0px;
17+
background-color: #E6E7E8;
18+
padding: 20px;
19+
border: 1px solid #BBBBBB;
20+
}
21+
22+
h2 {
23+
color: #00A5E3;
24+
font-size: 16px;
25+
font-weight: normal;
26+
margin-top: 50px;
27+
}
28+
29+
.code-comparison {
30+
width: 100%;
31+
}
32+
33+
.code-comparison td {
34+
border: 1px solid #CCCCCC;
35+
}
36+
37+
.code-comparison-title, .code-comparison-code {
38+
font-family: Arial, Helvetica, sans-serif;
39+
font-size: 12px;
40+
color: #000000;
41+
vertical-align: top;
42+
padding: 4px;
43+
width: 50%;
44+
background-color: #F1F1F1;
45+
line-height: 15px;
46+
}
47+
48+
.code-comparison-code {
49+
font-family: Courier;
50+
background-color: #F9F9F9;
51+
}
52+
53+
.code-comparison-highlight {
54+
background-color: #DDF1F7;
55+
border: 1px solid #00A5E3;
56+
line-height: 15px;
57+
}
58+
59+
.tag-line {
60+
text-align: center;
61+
width: 100%;
62+
margin-top: 30px;
63+
font-size: 12px;
64+
}
65+
66+
.tag-line a {
67+
color: #000000;
68+
}
69+
</style>
70+
</head>
71+
<body>
72+
<h1>GeneratorTest Coding Standards</h1>
73+
<a name="Code-Comparison,-blank-lines" />
74+
<h2>Code Comparison, blank lines</h2>
75+
<p class="text">This is a standard block.</p>
76+
<table class="code-comparison">
77+
<tr>
78+
<td class="code-comparison-title">Valid: Checking handling of blank lines.</td>
79+
<td class="code-comparison-title">Invalid: Checking handling of blank lines.</td>
80+
</tr>
81+
<tr>
82+
<td class="code-comparison-code">//&nbsp;First&nbsp;line&nbsp;of&nbsp;the&nbsp;code&nbsp;sample&nbsp;is</br>//&nbsp;deliberately&nbsp;empty.</br></br>//&nbsp;We&nbsp;also&nbsp;have&nbsp;a&nbsp;blank&nbsp;line&nbsp;in&nbsp;the&nbsp;middle.</br></br>//&nbsp;And&nbsp;a&nbsp;blank&nbsp;line&nbsp;at&nbsp;the&nbsp;end.</td>
83+
<td class="code-comparison-code">//&nbsp;First&nbsp;line&nbsp;of&nbsp;the&nbsp;code&nbsp;sample&nbsp;is</br>//&nbsp;deliberately&nbsp;empty.</br></br>//&nbsp;We&nbsp;also&nbsp;have&nbsp;a&nbsp;blank&nbsp;line&nbsp;in&nbsp;the&nbsp;middle.</br></br>//&nbsp;And&nbsp;a&nbsp;blank&nbsp;line&nbsp;at&nbsp;the&nbsp;end.</td>
84+
</tr>
85+
</table>
86+
<div class="tag-line">Documentation generated on #REDACTED# by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer #VERSION#</a></div>
87+
</body>
88+
</html>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# GeneratorTest Coding Standard
2+
3+
## Code Comparison, blank lines
4+
This is a standard block.
5+
<table>
6+
<tr>
7+
<th>Valid: Checking handling of blank lines.</th>
8+
<th>Invalid: Checking handling of blank lines.</th>
9+
</tr>
10+
<tr>
11+
<td>
12+
13+
// First line of the code sample is
14+
// deliberately empty.
15+
16+
// We also have a blank line in the middle.
17+
18+
// And a blank line at the end.
19+
20+
</td>
21+
<td>
22+
23+
// First line of the code sample is
24+
// deliberately empty.
25+
26+
// We also have a blank line in the middle.
27+
28+
// And a blank line at the end.
29+
30+
</td>
31+
</tr>
32+
</table>
33+
34+
Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
---------------------------------------------------------------
3+
| GENERATORTEST CODING STANDARD: CODE COMPARISON, BLANK LINES |
4+
---------------------------------------------------------------
5+
6+
This is a standard block.
7+
8+
----------------------------------------- CODE COMPARISON ------------------------------------------
9+
| Valid: Checking handling of blank lines. | Invalid: Checking handling of blank lines. |
10+
----------------------------------------------------------------------------------------------------
11+
| // First line of the code sample is | // First line of the code sample is |
12+
| // deliberately empty. | // deliberately empty. |
13+
| | |
14+
| // We also have a blank line in the middle. | // We also have a blank line in the middle. |
15+
| | |
16+
| // And a blank line at the end. | // And a blank line at the end. |
17+
----------------------------------------------------------------------------------------------------
18+
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<html>
2+
<head>
3+
<title>GeneratorTest Coding Standards</title>
4+
<style>
5+
body {
6+
background-color: #FFFFFF;
7+
font-size: 14px;
8+
font-family: Arial, Helvetica, sans-serif;
9+
color: #000000;
10+
}
11+
12+
h1 {
13+
color: #666666;
14+
font-size: 20px;
15+
font-weight: bold;
16+
margin-top: 0px;
17+
background-color: #E6E7E8;
18+
padding: 20px;
19+
border: 1px solid #BBBBBB;
20+
}
21+
22+
h2 {
23+
color: #00A5E3;
24+
font-size: 16px;
25+
font-weight: normal;
26+
margin-top: 50px;
27+
}
28+
29+
.code-comparison {
30+
width: 100%;
31+
}
32+
33+
.code-comparison td {
34+
border: 1px solid #CCCCCC;
35+
}
36+
37+
.code-comparison-title, .code-comparison-code {
38+
font-family: Arial, Helvetica, sans-serif;
39+
font-size: 12px;
40+
color: #000000;
41+
vertical-align: top;
42+
padding: 4px;
43+
width: 50%;
44+
background-color: #F1F1F1;
45+
line-height: 15px;
46+
}
47+
48+
.code-comparison-code {
49+
font-family: Courier;
50+
background-color: #F9F9F9;
51+
}
52+
53+
.code-comparison-highlight {
54+
background-color: #DDF1F7;
55+
border: 1px solid #00A5E3;
56+
line-height: 15px;
57+
}
58+
59+
.tag-line {
60+
text-align: center;
61+
width: 100%;
62+
margin-top: 30px;
63+
font-size: 12px;
64+
}
65+
66+
.tag-line a {
67+
color: #000000;
68+
}
69+
</style>
70+
</head>
71+
<body>
72+
<h1>GeneratorTest Coding Standards</h1>
73+
<a name="Code-Comparison,-block-length" />
74+
<h2>Code Comparison, block length</h2>
75+
<p class="text">This is a standard block.</p>
76+
<table class="code-comparison">
77+
<tr>
78+
<td class="code-comparison-title">Valid: code sample A has more lines than B.</td>
79+
<td class="code-comparison-title">Invalid: shorter.</td>
80+
</tr>
81+
<tr>
82+
<td class="code-comparison-code">//&nbsp;This&nbsp;code&nbsp;sample&nbsp;has&nbsp;more&nbsp;lines</br>//&nbsp;than&nbsp;the&nbsp;"invalid"&nbsp;one.</br><span class="code-comparison-highlight">$one</span>&nbsp;=&nbsp;10;</td>
83+
<td class="code-comparison-code"><span class="code-comparison-highlight">$a</span>&nbsp;=&nbsp;10;</td>
84+
</tr>
85+
</table>
86+
<table class="code-comparison">
87+
<tr>
88+
<td class="code-comparison-title">Valid: shorter.</td>
89+
<td class="code-comparison-title">Invalid: code sample B has more lines than A.</td>
90+
</tr>
91+
<tr>
92+
<td class="code-comparison-code"><span class="code-comparison-highlight">echo</span>&nbsp;$foo;</td>
93+
<td class="code-comparison-code">//&nbsp;This&nbsp;code&nbsp;sample&nbsp;has&nbsp;more&nbsp;lines</br>//&nbsp;than&nbsp;the&nbsp;"valid"&nbsp;one.</br><span class="code-comparison-highlight">print</span>&nbsp;$foo;</td>
94+
</tr>
95+
</table>
96+
<div class="tag-line">Documentation generated on #REDACTED# by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer #VERSION#</a></div>
97+
</body>
98+
</html>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# GeneratorTest Coding Standard
2+
3+
## Code Comparison, block length
4+
This is a standard block.
5+
<table>
6+
<tr>
7+
<th>Valid: code sample A has more lines than B.</th>
8+
<th>Invalid: shorter.</th>
9+
</tr>
10+
<tr>
11+
<td>
12+
13+
// This code sample has more lines
14+
// than the "invalid" one.
15+
$one = 10;
16+
17+
</td>
18+
<td>
19+
20+
$a = 10;
21+
22+
</td>
23+
</tr>
24+
</table>
25+
<table>
26+
<tr>
27+
<th>Valid: shorter.</th>
28+
<th>Invalid: code sample B has more lines than A.</th>
29+
</tr>
30+
<tr>
31+
<td>
32+
33+
echo $foo;
34+
35+
</td>
36+
<td>
37+
38+
// This code sample has more lines
39+
// than the "valid" one.
40+
print $foo;
41+
42+
</td>
43+
</tr>
44+
</table>
45+
46+
Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
----------------------------------------------------------------
3+
| GENERATORTEST CODING STANDARD: CODE COMPARISON, BLOCK LENGTH |
4+
----------------------------------------------------------------
5+
6+
This is a standard block.
7+
8+
----------------------------------------- CODE COMPARISON ------------------------------------------
9+
| Valid: code sample A has more lines than B. | Invalid: shorter. |
10+
----------------------------------------------------------------------------------------------------
11+
| // This code sample has more lines | $a = 10; |
12+
| // than the "invalid" one. | |
13+
| $one = 10; | |
14+
----------------------------------------------------------------------------------------------------
15+
16+
----------------------------------------- CODE COMPARISON ------------------------------------------
17+
| Valid: shorter. | Invalid: code sample B has more lines than A. |
18+
----------------------------------------------------------------------------------------------------
19+
| echo $foo; | // This code sample has more lines |
20+
| | // than the "valid" one. |
21+
| | print $foo; |
22+
----------------------------------------------------------------------------------------------------
23+

0 commit comments

Comments
 (0)