Make WordPress Core

Changeset 53510


Ignore:
Timestamp:
06/15/2022 02:42:58 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSameSets() in some newly introduced tests.

This ensures that not only the array values being compared are equal, but also that their type is the same.

Going forward, stricter type checking by using assertSameSets() or assertSameSetsWithIndex() should generally be preferred, to make the tests more reliable.

Follow-up to [48939], [51137], [51943], [53499], [53504], [53506], [53509].

See #55652.

Location:
trunk/tests/phpunit/tests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/nav-menu.php

    r53509 r53510  
    231231                $args = $action->get_args();
    232232                $last = end( $args );
    233                 $this->assertEqualSets( array( $post_id ), $last[1], '_prime_post_caches() was not executed.' );
     233                $this->assertSameSets( array( $post_id ), $last[1], '_prime_post_caches() was not executed.' );
    234234        }
    235235
    … …  
    263263                $args = $action->get_args();
    264264                $last = end( $args );
    265                 $this->assertEqualSets( array( $term_id ), $last[1], '_prime_term_caches() was not executed.' );
     265                $this->assertSameSets( array( $term_id ), $last[1], '_prime_term_caches() was not executed.' );
    266266        }
    267267
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r53509 r53510  
    15491549                $last = end( $args );
    15501550                $this->assertIsArray( $last, 'The last value is not an array' );
    1551                 $this->assertEqualSets( $attachment_ids, $last[1] );
     1551                $this->assertSameSets( $attachment_ids, $last[1] );
    15521552        }
    15531553
    … …  
    15921592                $last = end( $args );
    15931593                $this->assertIsArray( $last, 'The last value is not an array' );
    1594                 $this->assertEqualSets( $parent_ids, $last[1] );
     1594                $this->assertSameSets( $parent_ids, $last[1] );
    15951595        }
    15961596
  • trunk/tests/phpunit/tests/rest-api/rest-users-controller.php

    r52075 r53510  
    193193                $data     = $response->get_data();
    194194                $keys     = array_keys( $data['endpoints'][0]['args'] );
    195                 $this->assertEqualSets(
     195                $this->assertSameSets(
    196196                        array(
    197197                                'context',
Note: See TracChangeset for help on using the changeset viewer.