Make WordPress Core

Changeset 54053


Ignore:
Timestamp:
09/01/2022 05:04:52 PM (23 months ago)
Author:
flixos90
Message:

Site Health: Refine persistent object cache check tests.

This changeset makes these tests more reliable by having them less affected by external environment factors, fixing occasional failures.

See #56040.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/site-health.php

    r54047 r54053  
    363363     * @ticket 56040
    364364     */
    365     public function test_object_cache_default_thresholds() {
    366         $wp_site_health = new WP_Site_Health();
     365    public function test_object_cache_default_thresholds_non_multisite() {
     366        $wp_site_health = new WP_Site_Health();
     367
     368        // Set thresholds so high they should never be exceeded.
     369        add_filter(
     370            'site_status_persistent_object_cache_thresholds',
     371            function() {
     372                return array(
     373                    'alloptions_count' => PHP_INT_MAX,
     374                    'alloptions_bytes' => PHP_INT_MAX,
     375                    'comments_count'   => PHP_INT_MAX,
     376                    'options_count'    => PHP_INT_MAX,
     377                    'posts_count'      => PHP_INT_MAX,
     378                    'terms_count'      => PHP_INT_MAX,
     379                    'users_count'      => PHP_INT_MAX,
     380                );
     381            }
     382        );
    367383
    368384        $this->assertFalse(
     
    388404    public function test_object_cache_thresholds_check_can_be_bypassed() {
    389405        $wp_site_health = new WP_Site_Health();
     406
    390407        add_filter( 'site_status_should_suggest_persistent_object_cache', '__return_true' );
    391 
    392408        $this->assertTrue(
     409            $wp_site_health->should_suggest_persistent_object_cache()
     410        );
     411
     412        add_filter( 'site_status_should_suggest_persistent_object_cache', '__return_false', 11 );
     413        $this->assertFalse(
    393414            $wp_site_health->should_suggest_persistent_object_cache()
    394415        );
Note: See TracChangeset for help on using the changeset viewer.