Skip to content

Commit afb6fb0

Browse files
committed
WP/EnqueuedResourceParameters: move parse error test to its own file
1 parent ede46ef commit afb6fb0

File tree

3 files changed

+52
-30
lines changed

3 files changed

+52
-30
lines changed

WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc renamed to WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.1.inc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,3 @@ wp_register_script( 'someScript-js', $url, [], 0_0.0_0, true ); // Error - 0, fa
8383

8484
// Safeguard handling of PHP 8.1 explicit octals.
8585
wp_register_script( 'someScript-js', $url, [], 0o0, true ); // Error - 0, false or NULL are not allowed.
86-
87-
// Live coding/parse error.
88-
wp_register_style( src: 'https://example.com/someScript.js', ver: /*to do*/, handle: 'someScript-js', );
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
// Live coding/parse error.
4+
// This should be the only test in the file.
5+
wp_register_style( src: 'https://example.com/someScript.js', ver: /*to do*/, handle: 'someScript-js', );

WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,61 @@ final class EnqueuedResourceParametersUnitTest extends AbstractSniffUnitTest {
2323
/**
2424
* Returns the lines where errors should occur.
2525
*
26+
* @param string $testFile The name of the file being tested.
27+
*
2628
* @return array<int, int> Key is the line number, value is the number of expected errors.
2729
*/
28-
public function getErrorList() {
29-
return array(
30-
6 => 1,
31-
9 => 1,
32-
10 => 1,
33-
12 => 1,
34-
13 => 1,
35-
14 => 1,
36-
22 => 1,
37-
54 => 1,
38-
57 => 1,
39-
61 => 1,
40-
82 => 1,
41-
85 => 1,
42-
88 => 1,
43-
);
30+
public function getErrorList( $testFile = '' ) {
31+
switch ( $testFile ) {
32+
case 'EnqueuedResourceParametersUnitTest.1.inc':
33+
return array(
34+
6 => 1,
35+
9 => 1,
36+
10 => 1,
37+
12 => 1,
38+
13 => 1,
39+
14 => 1,
40+
22 => 1,
41+
54 => 1,
42+
57 => 1,
43+
61 => 1,
44+
82 => 1,
45+
85 => 1,
46+
);
47+
48+
case 'EnqueuedResourceParametersUnitTest.2.inc':
49+
return array(
50+
5 => 1,
51+
);
52+
53+
default:
54+
return array();
55+
}
4456
}
4557

4658
/**
4759
* Returns the lines where warnings should occur.
4860
*
61+
* @param string $testFile The name of the file being tested.
62+
*
4963
* @return array<int, int> Key is the line number, value is the number of expected warnings.
5064
*/
51-
public function getWarningList() {
52-
return array(
53-
3 => 2,
54-
11 => 1,
55-
32 => 1,
56-
39 => 2,
57-
42 => 1,
58-
45 => 1,
59-
66 => 2,
60-
77 => 1,
61-
);
65+
public function getWarningList( $testFile = '' ) {
66+
switch ( $testFile ) {
67+
case 'EnqueuedResourceParametersUnitTest.1.inc':
68+
return array(
69+
3 => 2,
70+
11 => 1,
71+
32 => 1,
72+
39 => 2,
73+
42 => 1,
74+
45 => 1,
75+
66 => 2,
76+
77 => 1,
77+
);
78+
79+
default:
80+
return array();
81+
}
6282
}
6383
}

0 commit comments

Comments
 (0)