Make WordPress Core


Ignore:
Timestamp:
06/07/2021 11:16:29 AM (3 years ago)
Author:
SergeyBiryukov
Message:

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

This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using assertSame() should generally be preferred to assertEquals() where appropriate, to make the tests more reliable.

Follow-up to [50380], [50959], [50960], [50973], [50993], [51003], [51051], [51054].

See #52482.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-sidebars-controller.php

    r50995 r51079  
    133133        $data     = $response->get_data();
    134134
    135         $this->assertEquals( array(), $data );
     135        $this->assertSame( array(), $data );
    136136    }
    137137
     
    171171        $data     = $response->get_data();
    172172        $data     = $this->remove_links( $data );
    173         $this->assertEquals(
     173        $this->assertSame(
    174174            array(
    175175                array(
     
    177177                    'name'          => 'Test sidebar',
    178178                    'description'   => '',
    179                     'status'        => 'active',
    180                     'widgets'       => array(),
    181179                    'class'         => '',
    182180                    'before_widget' => '',
     
    184182                    'before_title'  => '',
    185183                    'after_title'   => '',
     184                    'status'        => 'active',
     185                    'widgets'       => array(),
    186186                ),
    187187            ),
     
    220220        $data     = $response->get_data();
    221221        $data     = $this->remove_links( $data );
    222         $this->assertEquals(
     222        $this->assertSame(
    223223            array(
    224224                array(
     
    226226                    'name'          => 'Test sidebar',
    227227                    'description'   => '',
     228                    'class'         => '',
     229                    'before_widget' => '',
     230                    'after_widget'  => '',
     231                    'before_title'  => '',
     232                    'after_title'   => '',
    228233                    'status'        => 'active',
    229234                    'widgets'       => array(
     
    231236                        'rss-1',
    232237                    ),
    233                     'class'         => '',
    234                     'before_widget' => '',
    235                     'after_widget'  => '',
    236                     'before_title'  => '',
    237                     'after_title'   => '',
    238238                ),
    239239            ),
     
    257257        $data     = $response->get_data();
    258258        $data     = $this->remove_links( $data );
    259         $this->assertEquals(
     259        $this->assertSame(
    260260            array(
    261261                'id'            => 'sidebar-1',
    262262                'name'          => 'Test sidebar',
    263263                'description'   => '',
    264                 'status'        => 'active',
    265                 'widgets'       => array(),
    266264                'class'         => '',
    267265                'before_widget' => '',
     
    269267                'before_title'  => '',
    270268                'after_title'   => '',
     269                'status'        => 'active',
     270                'widgets'       => array(),
    271271            ),
    272272            $data
     
    359359        $data     = $response->get_data();
    360360        $data     = $this->remove_links( $data );
    361         $this->assertEquals(
     361        $this->assertSame(
    362362            array(
    363363                'id'            => 'sidebar-1',
    364364                'name'          => 'Test sidebar',
    365365                'description'   => '',
    366                 'status'        => 'active',
    367                 'widgets'       => array(
    368                     'text-1',
    369                     'text-2',
    370                 ),
    371366                'class'         => '',
    372367                'before_widget' => '',
     
    374369                'before_title'  => '',
    375370                'after_title'   => '',
     371                'status'        => 'active',
     372                'widgets'       => array(
     373                    'text-1',
     374                    'text-2',
     375                ),
    376376            ),
    377377            $data
     
    502502        $data     = $response->get_data();
    503503        $data     = $this->remove_links( $data );
    504         $this->assertEquals(
     504        $this->assertSame(
    505505            array(
    506506                array(
     
    508508                    'name'          => 'Test sidebar',
    509509                    'description'   => '',
    510                     'status'        => 'active',
    511                     'widgets'       => array(
    512                         'text-1',
    513                     ),
    514510                    'class'         => '',
    515511                    'before_widget' => '',
     
    517513                    'before_title'  => '',
    518514                    'after_title'   => '',
     515                    'status'        => 'active',
     516                    'widgets'       => array(
     517                        'text-1',
     518                    ),
    519519                ),
    520520                array(
     
    522522                    'name'          => 'Inactive widgets',
    523523                    'description'   => '',
    524                     'status'        => 'inactive',
    525                     'widgets'       => array(
    526                         'rss-1',
    527                     ),
    528524                    'class'         => '',
    529525                    'before_widget' => '',
     
    531527                    'before_title'  => '',
    532528                    'after_title'   => '',
     529                    'status'        => 'inactive',
     530                    'widgets'       => array(
     531                        'rss-1',
     532                    ),
    533533                ),
    534534            ),
Note: See TracChangeset for help on using the changeset viewer.