Skip to content

Commit b52dad5

Browse files
committed
Performance/LowExpiryCacheTime: move a parse error test to own test case file
1 parent ecdc10c commit b52dad5

File tree

3 files changed

+51
-38
lines changed

3 files changed

+51
-38
lines changed

WordPressVIPMinimum/Tests/Performance/LowExpiryCacheTimeUnitTest.inc renamed to WordPressVIPMinimum/Tests/Performance/LowExpiryCacheTimeUnitTest.1.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ wp_cache_add( 'test', $data, $group, WEEK_IN_SECONDS / 3 + HOUR_IN_SECONDS ); /
8686
wp_cache_set( $key, $data, '', (24 * 60 * 60) ); // OK.
8787
wp_cache_set( $key, $data, '', (-(2 * 60) + 600) ); // OK.
8888
wp_cache_set( $key, $data, '', (2 * 60) ); // Bad.
89-
wp_cache_set( $key, $data, '', (-(2 * 60) + 600 ); // OK - includes parse error, close parenthesis missing.
89+
9090

9191
// Test handling of numbers passed as strings.
9292
wp_cache_set( 'test', $data, $group, '300' ); // OK - type cast to integer within the function.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
// Parse error/live coding (missing close parentheses).
4+
// This should be the only test in this file.
5+
wp_cache_set( $key, $data, '', (-(2 * 60) + 600 ); // OK.

WordPressVIPMinimum/Tests/Performance/LowExpiryCacheTimeUnitTest.php

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,44 +28,52 @@ public function getErrorList() {
2828
/**
2929
* Returns the lines where warnings should occur.
3030
*
31+
* @param string $testFile The name of the file being tested.
32+
*
3133
* @return array<int, int> Key is the line number, value is the number of expected warnings.
3234
*/
33-
public function getWarningList() {
34-
return [
35-
27 => 1,
36-
28 => 1,
37-
29 => 1,
38-
30 => 1,
39-
32 => 1,
40-
33 => 1,
41-
34 => 1,
42-
35 => 1,
43-
37 => 1,
44-
38 => 1,
45-
39 => 1,
46-
40 => 1,
47-
47 => 1,
48-
52 => 1,
49-
56 => 1,
50-
74 => 1,
51-
75 => 1,
52-
76 => 1,
53-
77 => 1,
54-
78 => 1,
55-
79 => 1,
56-
82 => ( PHP_VERSION_ID > 50600 ) ? 0 : 1,
57-
88 => 1,
58-
94 => 1,
59-
95 => 1,
60-
105 => 1,
61-
112 => 1,
62-
113 => 1,
63-
114 => 1,
64-
115 => 1,
65-
116 => 1,
66-
119 => 1,
67-
120 => 1,
68-
123 => 1,
69-
];
35+
public function getWarningList( $testFile = '' ) {
36+
switch ( $testFile ) {
37+
case 'LowExpiryCacheTimeUnitTest.1.inc':
38+
return [
39+
27 => 1,
40+
28 => 1,
41+
29 => 1,
42+
30 => 1,
43+
32 => 1,
44+
33 => 1,
45+
34 => 1,
46+
35 => 1,
47+
37 => 1,
48+
38 => 1,
49+
39 => 1,
50+
40 => 1,
51+
47 => 1,
52+
52 => 1,
53+
56 => 1,
54+
74 => 1,
55+
75 => 1,
56+
76 => 1,
57+
77 => 1,
58+
78 => 1,
59+
79 => 1,
60+
82 => ( PHP_VERSION_ID > 50600 ) ? 0 : 1,
61+
88 => 1,
62+
94 => 1,
63+
95 => 1,
64+
105 => 1,
65+
112 => 1,
66+
113 => 1,
67+
114 => 1,
68+
115 => 1,
69+
116 => 1,
70+
119 => 1,
71+
120 => 1,
72+
123 => 1,
73+
];
74+
75+
default:
76+
return [];
77+
}
7078
}
7179
}

0 commit comments

Comments
 (0)