Skip to content

Commit

Permalink
Generators: add tests for handling code samples
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrfnl committed Nov 23, 2024
1 parent 9819deb commit 87d5030
Show file tree
Hide file tree
Showing 23 changed files with 836 additions and 0 deletions.
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">//&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>
<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>
</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>
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)
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. |
----------------------------------------------------------------------------------------------------

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">//&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>
<td class="code-comparison-code"><span class="code-comparison-highlight">$a</span>&nbsp;=&nbsp;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>&nbsp;$foo;</td>
<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>
</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>
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)
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; |
----------------------------------------------------------------------------------------------------

Loading

0 comments on commit 87d5030

Please sign in to comment.