WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (17 months ago)
Author:
SergeyBiryukov
Message:

Tests: First pass at using assertSame() instead of assertEquals() in most of the unit 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.

Props johnbillion, jrf, SergeyBiryukov.
See #38266.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/blocks/register.php

    r48263 r48937  
    293293        $this->assertSame( 'Shows warning, error or success notices…', $result->description );
    294294        $this->assertEqualSets( array( 'alert', 'message' ), $result->keywords );
    295         $this->assertEquals(
     295        $this->assertSame(
    296296            array(
    297297                'message' => array(
     
    303303            $result->attributes
    304304        );
    305         $this->assertEquals(
     305        $this->assertSame(
    306306            array(
    307307                'my-plugin/message' => 'message',
     
    310310        );
    311311        $this->assertEqualSets( array( 'groupId' ), $result->uses_context );
    312         $this->assertEquals(
     312        $this->assertSame(
    313313            array(
    314314                'align'             => true,
     
    317317            $result->supports
    318318        );
    319         $this->assertEquals(
     319        $this->assertSame(
    320320            array(
    321321                array(
     
    331331            $result->styles
    332332        );
    333         $this->assertEquals(
     333        $this->assertSame(
    334334            array(
    335335                'attributes' => array(
     
    397397        $registry   = WP_Block_Type_Registry::get_instance();
    398398        $block_type = $registry->get_registered( 'core/test-filtered' );
    399         $this->assertEquals( 'boolean', $block_type->attributes['core/test-filtered']['type'] );
     399        $this->assertSame( 'boolean', $block_type->attributes['core/test-filtered']['type'] );
    400400    }
    401401}
Note: See TracChangeset for help on using the changeset viewer.