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/block-type.php

    r47876 r48937  
    101101        );
    102102        $output     = $block_type->render( $attributes );
    103         $this->assertEquals( $attributes, json_decode( $output, true ) );
     103        $this->assertSame( $attributes, json_decode( $output, true ) );
    104104    }
    105105
     
    124124        );
    125125        $output     = $block_type->render( $attributes, $content );
    126         $this->assertEquals( $expected, json_decode( $output, true ) );
     126        $this->assertSame( $expected, json_decode( $output, true ) );
    127127    }
    128128
     
    134134        $output     = $block_type->render();
    135135
    136         $this->assertEquals( '', $output );
     136        $this->assertSame( '', $output );
    137137    }
    138138
     
    224224        $prepared_attributes = $block_type->prepare_attributes_for_render( $attributes );
    225225
    226         $this->assertEquals( $attributes, $prepared_attributes );
     226        $this->assertSame( $attributes, $prepared_attributes );
    227227    }
    228228
Note: See TracChangeset for help on using the changeset viewer.