Skip to content

Commit 82ce04a

Browse files
committed
LowExpiryCacheTime: add a few more unit tests
... safeguarding that certain situations are handled correctly and documenting the sniff behaviour in those cases.
1 parent 0340d86 commit 82ce04a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

WordPressVIPMinimum/Tests/Performance/LowExpiryCacheTimeUnitTest.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,10 @@ wp_cache_set( 'test', $data, $group, HOUR_IN_SECONDS::methodName() ); // Bad - n
114114
wp_cache_set( 'test', $data, $group, $obj->MONTH_IN_SECONDS ); // Bad - not a constant.
115115
wp_cache_set( 'test', $data, $group, $obj::MONTH_IN_SECONDS ); // Bad - not the WP constant.
116116
wp_cache_set( 'test', $data, $group, PluginNamespace\SubLevel\DAY_IN_SECONDS ); // Bad - not the WP constant.
117+
118+
// Test passing negative number as cache time.
119+
wp_cache_set( 'test', $data, $group, -300 ); // Bad.
120+
wp_cache_add( $testing, $data, 'test_group', -6 * MINUTE_IN_SECONDS ); // Bad.
121+
122+
// Test more complex logic in the parameter.
123+
wp_cache_add( $key, $data, '', ($toggle ? 200 : 400) ); // Manual inspection warning.

WordPressVIPMinimum/Tests/Performance/LowExpiryCacheTimeUnitTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public function getWarningList() {
6464
114 => 1,
6565
115 => 1,
6666
116 => 1,
67+
119 => 1,
68+
120 => 1,
69+
123 => 1,
6770
];
6871
}
6972
}

0 commit comments

Comments
 (0)