@@ -15,118 +15,39 @@ function test_object_cache_default_thresholds() {
1515 }
1616
1717 function test_object_cache_thresholds_check_can_be_bypassed () {
18- add_filter ( 'perflab_oc_site_status_persistent_object_cache_thresholds ' , '__return_true ' );
18+ add_filter ( 'perflab_oc_site_status_suggest_persistent_object_cache ' , '__return_true ' );
1919
2020 $ result = perflab_oc_health_should_persistent_object_cache ();
2121
2222 $ this ->assertTrue ( $ result );
23-
24- remove_all_filters ( 'perflab_oc_site_status_persistent_object_cache_thresholds ' );
25- }
26-
27- function test_object_cache_comments_threshold () {
28- add_filter (
29- 'perflab_oc_site_status_persistent_object_cache_thresholds ' ,
30- function ( $ thresholds ) {
31- return array_merge ( $ thresholds , array ( 'comments_count ' => 0 ) );
32- }
33- );
34-
35- $ result = perflab_oc_health_should_persistent_object_cache ();
36-
37- $ this ->assertTrue ( $ result );
38-
39- remove_all_filters ( 'perflab_oc_site_status_persistent_object_cache_thresholds ' );
40- }
41-
42- function test_object_cache_posts_threshold () {
43- add_filter (
44- 'perflab_oc_site_status_persistent_object_cache_thresholds ' ,
45- function ( $ thresholds ) {
46- return array_merge ( $ thresholds , array ( 'posts_count ' => 0 ) );
47- }
48- );
49-
50- $ result = perflab_oc_health_should_persistent_object_cache ();
51-
52- $ this ->assertTrue ( $ result );
53-
54- remove_all_filters ( 'perflab_oc_site_status_persistent_object_cache_thresholds ' );
55- }
56-
57- function test_object_cache_terms_threshold () {
58- add_filter (
59- 'perflab_oc_site_status_persistent_object_cache_thresholds ' ,
60- function ( $ thresholds ) {
61- return array_merge ( $ thresholds , array ( 'terms_count ' => 1 ) );
62- }
63- );
64-
65- $ result = perflab_oc_health_should_persistent_object_cache ();
66-
67- $ this ->assertTrue ( $ result );
68-
69- remove_all_filters ( 'perflab_oc_site_status_persistent_object_cache_thresholds ' );
7023 }
7124
72- function test_object_cache_options_threshold () {
25+ /**
26+ *
27+ * @dataProvider thresholds
28+ */
29+ function test_object_cache_thresholds ( $ threshold , $ count ) {
7330 add_filter (
7431 'perflab_oc_site_status_persistent_object_cache_thresholds ' ,
75- function ( $ thresholds ) {
76- return array_merge ( $ thresholds , array ( ' options_count ' => 100 ) );
32+ function ( $ thresholds ) use ( $ threshold , $ count ) {
33+ return array_merge ( $ thresholds , array ( $ threshold => $ count ) );
7734 }
7835 );
7936
8037 $ result = perflab_oc_health_should_persistent_object_cache ();
8138
8239 $ this ->assertTrue ( $ result );
83-
84- remove_all_filters ( 'perflab_oc_site_status_persistent_object_cache_thresholds ' );
8540 }
8641
87- function test_object_cache_users_threshold () {
88- add_filter (
89- 'perflab_oc_site_status_persistent_object_cache_thresholds ' ,
90- function ( $ thresholds ) {
91- return array_merge ( $ thresholds , array ( 'users_count ' => 0 ) );
92- }
42+ function thresholds () {
43+ return array (
44+ array ( 'comments_count ' , 0 ),
45+ array ( 'posts_count ' , 0 ),
46+ array ( 'terms_count ' , 1 ),
47+ array ( 'options_count ' , 100 ),
48+ array ( 'users_count ' , 0 ),
49+ array ( 'alloptions_count ' , 100 ),
50+ array ( 'alloptions_bytes ' , 1000 ),
9351 );
94-
95- $ result = perflab_oc_health_should_persistent_object_cache ();
96-
97- $ this ->assertTrue ( $ result );
98-
99- remove_all_filters ( 'perflab_oc_site_status_persistent_object_cache_thresholds ' );
10052 }
101-
102- function test_object_cache_alloptions_count_threshold () {
103- add_filter (
104- 'perflab_oc_site_status_persistent_object_cache_thresholds ' ,
105- function ( $ thresholds ) {
106- return array_merge ( $ thresholds , array ( 'alloptions_count ' => 100 ) );
107- }
108- );
109-
110- $ result = perflab_oc_health_should_persistent_object_cache ();
111-
112- $ this ->assertTrue ( $ result );
113-
114- remove_all_filters ( 'perflab_oc_site_status_persistent_object_cache_thresholds ' );
115- }
116-
117- function test_object_cache_alloptions_bytes_threshold () {
118- add_filter (
119- 'perflab_oc_site_status_persistent_object_cache_thresholds ' ,
120- function ( $ thresholds ) {
121- return array_merge ( $ thresholds , array ( 'alloptions_bytes ' => 1000 ) );
122- }
123- );
124-
125- $ result = perflab_oc_health_should_persistent_object_cache ();
126-
127- $ this ->assertTrue ( $ result );
128-
129- remove_all_filters ( 'perflab_oc_site_status_persistent_object_cache_thresholds ' );
130- }
131-
13253}
0 commit comments