Make WordPress Core

Changeset 64015


Ignore:
Timestamp:
09/30/2026 03:27:44 PM (6 weeks ago)
Author:
lancewillett
Message:

Tests: Document value comparisons in bookmark tests.

Explain why five assertEquals() calls intentionally compare bookmark objects by value. Cache retrieval and database queries return separate object instances, so identity comparisons would be inappropriate.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/13832

Props noruzzaman.
See #64895.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/bookmark/getBookmark.php

    r51568 r64015  
    144144                // Check the bookmark was cached.
    145145                $actual_cache = wp_cache_get( $bookmark->link_id, 'bookmark' );
     146
     147                // Keep assertEquals() because the objects are intentionally compared by value.
    146148                $this->assertEquals( $bookmark, $actual_cache );
    147149        }
    … …  
    233235                 */
    234236                if ( is_object( $expected ) ) {
     237                        // Keep assertEquals() because the objects are intentionally compared by value.
    235238                        $this->assertEquals( $expected, $actual_bookmark );
    236239                } else {
    … …  
    240243                // Check the bookmark was cached.
    241244                $actual_cache = wp_cache_get( self::$bookmark->link_id, 'bookmark' );
     245
     246                // Keep assertEquals() because the objects are intentionally compared by value.
    242247                $this->assertEquals( self::$bookmark, $actual_cache );
    243248        }
    … …  
    291296                 */
    292297                if ( is_object( $expected ) ) {
     298                        // Keep assertEquals() because the objects are intentionally compared by value.
    293299                        $this->assertEquals( $expected, $actual_bookmark );
    294300                } else {
    … …  
    298304                // Check the bookmark was cached.
    299305                $actual_cache = wp_cache_get( self::$bookmark->link_id, 'bookmark' );
     306
     307                // Keep assertEquals() because the objects are intentionally compared by value.
    300308                $this->assertEquals( self::$bookmark, $actual_cache );
    301309        }
Note: See TracChangeset for help on using the changeset viewer.