Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (3 years 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/render.php

    r47984 r48937  
    6161        $actual_html = do_blocks( $original_html );
    6262
    63         $this->assertEqualsIgnoreEOL( $expected_html, $actual_html );
     63        $this->assertSameIgnoreEOL( $expected_html, $actual_html );
    6464    }
    6565
     
    8181        remove_shortcode( 'someshortcode' );
    8282
    83         $this->assertEquals( trim( $classic_filtered_content ), trim( $block_filtered_content ) );
     83        $this->assertSame( trim( $classic_filtered_content ), trim( $block_filtered_content ) );
    8484    }
    8585
     
    122122        }
    123123
    124         $this->assertEquals( 'deep inside', do_blocks( $content ) );
     124        $this->assertSame( 'deep inside', do_blocks( $content ) );
    125125    }
    126126
     
    143143        );
    144144
    145         $this->assertEquals( $minimum_depth, (int) do_blocks( $content ) );
     145        $this->assertSame( $minimum_depth, (int) do_blocks( $content ) );
    146146    }
    147147
     
    161161        $filtered_content = trim( apply_filters( 'the_content', $test_content ) );
    162162
    163         $this->assertEquals( $expected_content, $filtered_content );
     163        $this->assertSame( $expected_content, $filtered_content );
    164164
    165165        // Check that wpautop() is still defined in the same place.
     
    175175        $filtered_content = trim( apply_filters( 'the_content', $test_content ) );
    176176
    177         $this->assertEquals( $expected_content, $filtered_content );
     177        $this->assertSame( $expected_content, $filtered_content );
    178178
    179179        $this->assertSame( $current_priority, has_action( 'the_content', 'wpautop' ) );
     
    223223        $expected_html = self::strip_r( file_get_contents( $server_html_path ) );
    224224
    225         $this->assertEquals(
     225        $this->assertSame(
    226226            $expected_html,
    227227            $html,
     
    253253
    254254        $updated_post_content = do_blocks( $post_content );
    255         $this->assertEquals(
     255        $this->assertSame(
    256256            $updated_post_content,
    257257            'before' .
     
    287287        do_blocks( '<!-- wp:core/test /-->' );
    288288
    289         $this->assertEquals( $global_post, $post );
     289        $this->assertSame( $global_post, $post );
    290290    }
    291291
     
    343343        $data = unserialize( base64_decode( $output ) );
    344344
    345         $this->assertEquals( 'inner', $data[1] );
     345        $this->assertSame( 'inner', $data[1] );
    346346    }
    347347
     
    371371        $data = unserialize( base64_decode( $output ) );
    372372
    373         $this->assertEquals( 'before10after', $data[1] );
     373        $this->assertSame( 'before10after', $data[1] );
    374374    }
    375375
     
    391391        $inner = $this->render_serialize_dynamic_block( array(), 'deep inner' );
    392392
    393         $this->assertEquals( $data[1], 'before' . $inner . 'after' );
     393        $this->assertSame( $data[1], 'before' . $inner . 'after' );
    394394    }
    395395
Note: See TracChangeset for help on using the changeset viewer.