Make WordPress Core

Changeset 64064


Ignore:
Timestamp:
10/02/2026 06:26:28 PM (8 weeks ago)
Author:
lancewillett
Message:

Tests: Document object value comparisons in POMO tests.

Explain why MO and PO tests retain assertEquals() for Translation_Entry objects. Expected entries and imported entries are distinct instances whose values should match.

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

Props huzaifaalmesbah.
See #64895.

Location:
trunk/tests/phpunit/tests/pomo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/pomo/mo.php

    r56548 r64064  
    5959                        )
    6060                );
     61                // Keep assertEquals() because the objects are intentionally compared by value.
    6162                $this->assertEquals( $plural_entry, $mo->entries[ $plural_entry->key() ] );
    6263                $this->assertSame( 'dragonland', $mo->entries[ $plural_entry->key() ]->context );
    … …  
    6970                        )
    7071                );
     72
     73                // Keep assertEquals() because the objects are intentionally compared by value.
    7174                $this->assertEquals( $single_entry, $mo->entries[ $single_entry->key() ] );
    7275                $this->assertSame( 'not so dragon', $mo->entries[ $single_entry->key() ]->context );
    … …  
    139142                $this->assertSame( count( $entries ), count( $again->entries ) );
    140143                foreach ( $entries as $entry ) {
     144                        // Keep assertEquals() because the objects are intentionally compared by value.
    141145                        $this->assertEquals( $entry, $again->entries[ $entry->key() ] );
    142146                }
  • trunk/tests/phpunit/tests/pomo/po.php

    r62093 r64064  
    283283
    284284                $simple_entry = new Translation_Entry( array( 'singular' => 'moon' ) );
     285                // Keep assertEquals() because the objects are intentionally compared by value.
    285286                $this->assertEquals( $simple_entry, $po->entries[ $simple_entry->key() ] );
    286287
    … …  
    293294                        )
    294295                );
     296                // Keep assertEquals() because the objects are intentionally compared by value.
    295297                $this->assertEquals( $all_types_entry, $po->entries[ $all_types_entry->key() ] );
    296298
    … …  
    301303                        )
    302304                );
     305                // Keep assertEquals() because the objects are intentionally compared by value.
    303306                $this->assertEquals( $multiple_line_entry, $po->entries[ $multiple_line_entry->key() ] );
    304307
    … …  
    311314                        )
    312315                );
     316                // Keep assertEquals() because the objects are intentionally compared by value.
    313317                $this->assertEquals( $multiple_line_all_types_entry, $po->entries[ $multiple_line_all_types_entry->key() ] );
    314318
    … …  
    322326                        )
    323327                );
     328                // Keep assertEquals() because the objects are intentionally compared by value.
    324329                $this->assertEquals( $comments_entry, $po->entries[ $comments_entry->key() ] );
    325330
    326331                $end_quote_entry = new Translation_Entry( array( 'singular' => 'a"' ) );
     332                // Keep assertEquals() because the objects are intentionally compared by value.
    327333                $this->assertEquals( $end_quote_entry, $po->entries[ $end_quote_entry->key() ] );
    328334        }
    … …  
    380386                );
    381387
     388                // Keep assertEquals() because the objects are intentionally compared by value.
    382389                $this->assertEquals( $po->entries, $entries, 'Failed for ' . $printable_newline );
    383390
Note: See TracChangeset for help on using the changeset viewer.