Skip to content

Commit 0bddda7

Browse files
committed
Make the examples in the CodeBlocksExtractorTest generic
1 parent d1b3569 commit 0bddda7

File tree

3 files changed

+22
-62
lines changed

3 files changed

+22
-62
lines changed

Tests/DocCodeExamples/CodeBlocksExtractorTest.php

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -135,45 +135,25 @@ public static function dataExtractCodeBlocks(): array
135135
'expectedResult' => [
136136
'valid' => [
137137
new CodeBlock(
138-
'Valid: Opening square bracket/parenthesis token of a multi-line array indented at least to the same level of the start of the statement.',
139-
'if ($condition) {
140-
$a =
141-
[
142-
1,
143-
2,
144-
];
145-
}',
138+
'Valid: Example of a valid code block.',
139+
'// Some PHP code that does not trigger the sniff.',
146140
0
147141
),
148142
new CodeBlock(
149-
'Valid: Elements of an array indented four spaces beyond the indentation level of the opening square bracket/parenthesis.',
150-
'$a = array(
151-
1,
152-
2,
153-
3,
154-
);',
143+
'Valid: Another example of a valid code block.',
144+
'// Another PHP code that does not trigger the sniff.',
155145
1
156146
),
157147
],
158148
'invalid' => [
159149
new CodeBlock(
160-
'Invalid: Opening square bracket/parenthesis of a multi-line array not indented at least to the same level of the start of the statement.',
161-
'if ($condition) {
162-
$a =
163-
[
164-
1,
165-
2,
166-
];
167-
}',
150+
'Invalid: Example of an invalid code block.',
151+
'// Some PHP code that does trigger the sniff.',
168152
2
169153
),
170154
new CodeBlock(
171-
'Invalid: Elements of an array not indented four spaces beyond the indentation level of the opening square bracket/parenthesis.',
172-
'$a = array(
173-
1,
174-
2,
175-
3,
176-
);',
155+
'Invalid: Another example of an invalid code block.',
156+
'// Another PHP code that does trigger the sniff.',
177157
3
178158
),
179159
],

Tests/Fixtures/DocCodeExamples/CodeBlocksExtractor/OneValidBlock.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
<documentation title="Array Indent">
1+
<documentation title="One Valid Block">
22
<standard>
33
<![CDATA[
4-
The opening square bracket/parenthesis of a multi-line array must be indented at least to the same level of the start of the statement.
4+
This is a test file with one valid code block.
55
]]>
66
</standard>
77
<code_comparison>
88
<code title="Valid: Example of a valid code block.">
99
<![CDATA[
10-
// Some PHP code.
10+
// Some PHP code.
1111
]]>
1212
</code>
1313
</code_comparison>

Tests/Fixtures/DocCodeExamples/CodeBlocksExtractor/ValidAndInvalidBlocks.xml

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,35 @@
1-
<documentation title="Array Indent">
1+
<documentation title="Valid And Invalid Blocks">
22
<standard>
33
<![CDATA[
4-
The opening square bracket/parenthesis of a multi-line array must be indented at least to the same level of the start of the statement.
4+
This is a test file with valid and invalid code blocks.
55
]]>
66
</standard>
77
<code_comparison>
8-
<code title="Valid: Opening square bracket/parenthesis token of a multi-line array indented at least to the same level of the start of the statement.">
8+
<code title="Valid: Example of a valid code block.">
99
<![CDATA[
10-
if ($condition) {
11-
$a =
12-
<em> [</em>
13-
1,
14-
2,
15-
];
16-
}
10+
// Some PHP code that does not trigger the sniff.
1711
]]>
1812
</code>
19-
<code title="Invalid: Opening square bracket/parenthesis of a multi-line array not indented at least to the same level of the start of the statement.">
13+
<code title="Invalid: Example of an invalid code block.">
2014
<![CDATA[
21-
if ($condition) {
22-
$a =
23-
<em>[</em>
24-
1,
25-
2,
26-
];
27-
}
15+
// Some PHP code that does trigger the sniff.
2816
]]>
2917
</code>
3018
</code_comparison>
3119
<standard>
3220
<![CDATA[
33-
The elements of an array must be indented four spaces beyond the indentation level of the opening square bracket/parenthesis.
21+
Another <standard> block in this test file with valid and invalid code blocks.
3422
]]>
3523
</standard>
3624
<code_comparison>
37-
<code title="Valid: Elements of an array indented four spaces beyond the indentation level of the opening square bracket/parenthesis.">
25+
<code title="Valid: Another example of a valid code block.">
3826
<![CDATA[
39-
$a = array(
40-
<em> 1</em>,
41-
<em> 2</em>,
42-
<em> 3</em>,
43-
);
27+
// Another PHP code that does not trigger the sniff.
4428
]]>
4529
</code>
46-
<code title="Invalid: Elements of an array not indented four spaces beyond the indentation level of the opening square bracket/parenthesis.">
30+
<code title="Invalid: Another example of an invalid code block.">
4731
<![CDATA[
48-
$a = array(
49-
<em> 1</em>,
50-
2,
51-
<em> 3</em>,
52-
);
32+
// Another PHP code that does trigger the sniff.
5333
]]>
5434
</code>
5535
</code_comparison>

0 commit comments

Comments
 (0)