Make WordPress Core

Changeset 64071


Ignore:
Timestamp:
10/02/2026 08:03:38 PM (2 days ago)
Author:
lancewillett
Message:

Tests: Document object value comparisons in post tests.

Explain why post lookup, metadata, post type label, and attachment count tests retain assertEquals() when comparing separately constructed or cached objects by value.

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

Props noruzzaman.
See #64895.

Location:
trunk/tests/phpunit/tests/post
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/getPageByPath.php

    r63915 r64071  
    3939
    4040                // get_page_by_path() should return a post of the requested type before returning an attachment.
     41                // Keep assertEquals() because the objects are intentionally compared by value.
    4142                $this->assertEquals( $page, get_page_by_path( 'some-page' ) );
    4243
    4344                // Make sure get_page_by_path() will still select an attachment when a post of the requested type doesn't exist.
     45                // Keep assertEquals() because the objects are intentionally compared by value.
    4446                $this->assertEquals( $other_att, get_page_by_path( 'some-other-page' ) );
    4547        }
  • trunk/tests/phpunit/tests/post/meta.php

    r56548 r64071  
    172172                $mobj->meta_key   = 'get_post_meta_by_key';
    173173                $mobj->meta_value = 'get_post_meta_by_key_value';
     174                // Keep assertEquals() because the objects are intentionally compared by value.
    174175                $this->assertEquals( $mobj, get_post_meta_by_id( $mid ) );
    175176                delete_metadata_by_mid( 'post', $mid );
    … …  
    179180                $mobj->meta_id    = $mid;
    180181                $mobj->meta_value = array( 'foo', 'bar' );
     182                // Keep assertEquals() because the objects are intentionally compared by value.
    181183                $this->assertEquals( $mobj, get_post_meta_by_id( $mid ) );
    182184                delete_metadata_by_mid( 'post', $mid );
  • trunk/tests/phpunit/tests/post/types.php

    r64009 r64071  
    293293                $after = get_post_type_object( 'foo' )->labels;
    294294
     295                // Keep assertEquals() because the objects are intentionally compared by value.
    295296                $this->assertEquals( $before, $after );
    296297
  • trunk/tests/phpunit/tests/post/wpCountAttachments.php

    r54255 r64071  
    2929                $actual   = wp_cache_get( $cache_key, 'counts' );
    3030
     31                // Keep assertEquals() because the objects are intentionally compared by value.
    3132                $this->assertEquals( $expected, $actual );
    3233        }
Note: See TracChangeset for help on using the changeset viewer.