Skip to:
Content

bbPress.org

Changeset 8033


Ignore:
Timestamp:
10/15/2026 09:58:08 PM (8 days ago)
Author:
johnjamesjacoby
Message:

Tests: Normalize randomized Gravatar hosts.

Normalize legacy numbered Gravatar hosts through the get_avatar_url filter during PHPUnit tests. This keeps repeated helper and output calls comparable across supported WordPress versions without changing production output.

In trunk, for 2.7.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase.php

    r7924 r8033  
    1515        public function setUp(): void {
    1616                parent::setUp();
     17                add_filter( 'get_avatar_url', array( $this, 'filter_gravatar_url' ) );
    1718
    1819                $this->factory = new BBP_UnitTest_Factory;
    … …  
    3435                global $wpdb;
    3536
     37                remove_filter( 'get_avatar_url', array( $this, 'filter_gravatar_url' ) );
    3638                parent::tearDown();
    3739
    … …  
    5153
    5254                $this->commit_transaction();
     55        }
     56
     57        /**
     58         * Normalize the randomly selected Gravatar server in generated URLs.
     59         *
     60         * @param string $url Gravatar URL.
     61         *
     62         * @return string Normalized Gravatar URL.
     63         */
     64        public function filter_gravatar_url( $url ) {
     65                return preg_replace( '|//[0-2]\.gravatar\.com|', '//secure.gravatar.com', $url );
    5366        }
    5467
Note: See TracChangeset for help on using the changeset viewer.