Make WordPress Core


Ignore:
Timestamp:
11/09/2020 03:43:14 PM (6 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 [48937], [48939], [48940], [48944].

See #38266.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase-block-supports.php

    r49545 r49547  
    124124                $style_list   = $this->get_attribute_from_block( 'style', $styled_block );
    125125
    126                 $this->assertEquals( $expected_classes, $class_list );
    127                 $this->assertEquals( $expected_styles, $style_list );
     126                $this->assertSame( $expected_classes, $class_list );
     127                $this->assertSame( $expected_styles, $style_list );
    128128        }
    129129
     
    139139
    140140                // Ensure blocks to not add extra whitespace.
    141                 $this->assertEquals( $styled_block, trim( $styled_block ) );
     141                $this->assertSame( $styled_block, trim( $styled_block ) );
    142142
    143143                $content    = $this->get_content_from_block( $styled_block );
     
    145145                $style_list = $this->get_attribute_from_block( 'style', $styled_block );
    146146
    147                 $this->assertEquals( self::BLOCK_CONTENT, $content );
    148                 $this->assertEqualSets(
     147                $this->assertSame( self::BLOCK_CONTENT, $content );
     148                $this->assertSameSets(
    149149                        explode( ' ', $expected_classes ),
    150150                        explode( ' ', $class_list )
    151151                );
    152                 $this->assertEquals(
     152                $this->assertSame(
    153153                        array_map( 'trim', explode( ';', $expected_styles ) ),
    154154                        array_map( 'trim', explode( ';', $style_list ) )
Note: See TracChangeset for help on using the changeset viewer.