Make WordPress Core

Changeset 58181


Ignore:
Timestamp:
05/21/2024 10:31:51 AM (5 weeks ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSame() in block support 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.

Includes renaming a few test classes per the naming conventions.

Reference: Writing PHP Tests: Naming and Organization.

Follow-up to [53076], [53085], [54497], [56046], [56614], [57246], [57491].

See #60705.

Location:
trunk/tests/phpunit/tests/block-supports
Files:
7 edited

Legend:

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

    r56479 r58181  
    55 * @covers ::wp_apply_border_support
    66 */
    7 class Test_Block_Supports_Border extends WP_UnitTestCase {
     7class Tests_Block_Supports_Border extends WP_UnitTestCase {
    88    /**
    99     * @var string|null
  • trunk/tests/phpunit/tests/block-supports/layout.php

    r58170 r58181  
    1111 * @covers ::wp_restore_image_outer_container
    1212 */
    13 class Test_Block_Supports_Layout extends WP_UnitTestCase {
     13class Tests_Block_Supports_Layout extends WP_UnitTestCase {
    1414
    1515    /**
     
    311311    public function test_restore_group_inner_container( $args, $expected_output ) {
    312312        $actual_output = wp_restore_group_inner_container( $args['block_content'], $args['block'] );
    313         $this->assertEquals( $expected_output, $actual_output );
     313        $this->assertSame( $expected_output, $actual_output );
    314314    }
    315315
  • trunk/tests/phpunit/tests/block-supports/shadow.php

    r56479 r58181  
    55 * @covers ::wp_apply_shadow_support
    66 */
    7 class Test_Block_Supports_Shadow extends WP_UnitTestCase {
     7class Tests_Block_Supports_Shadow extends WP_UnitTestCase {
    88    /**
    99     * @var string|null
  • trunk/tests/phpunit/tests/block-supports/spacing.php

    r56479 r58181  
    55 * @covers ::wp_apply_spacing_support
    66 */
    7 class Test_Block_Supports_Spacing extends WP_UnitTestCase {
     7class Tests_Block_Supports_Spacing extends WP_UnitTestCase {
    88    /**
    99     * @var string|null
  • trunk/tests/phpunit/tests/block-supports/typography.php

    r58171 r58181  
    11191119     */
    11201120    public function test_valid_size_wp_get_typography_value_and_unit( $raw_value, $expected ) {
    1121         $this->assertEquals( $expected, wp_get_typography_value_and_unit( $raw_value ) );
     1121        $this->assertSame( $expected, wp_get_typography_value_and_unit( $raw_value ) );
    11221122    }
    11231123
     
    11441144                'raw_value' => '10',
    11451145                'expected'  => array(
    1146                     'value' => 10,
     1146                    'value' => 10.0,
    11471147                    'unit'  => 'px',
    11481148                ),
     
    11511151                'raw_value' => 11,
    11521152                'expected'  => array(
    1153                     'value' => 11,
     1153                    'value' => 11.0,
    11541154                    'unit'  => 'px',
    11551155                ),
     
    11651165                'raw_value' => '12rem',
    11661166                'expected'  => array(
    1167                     'value' => 12,
     1167                    'value' => 12.0,
    11681168                    'unit'  => 'rem',
    11691169                ),
     
    11721172                'raw_value' => '12px',
    11731173                'expected'  => array(
    1174                     'value' => 12,
     1174                    'value' => 12.0,
    11751175                    'unit'  => 'px',
    11761176                ),
     
    11791179                'raw_value' => '12em',
    11801180                'expected'  => array(
    1181                     'value' => 12,
     1181                    'value' => 12.0,
    11821182                    'unit'  => 'em',
    11831183                ),
  • trunk/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php

    r57254 r58181  
    111111        $actual = wp_render_background_support( $wrapper, $block );
    112112
    113         $this->assertEquals(
     113        $this->assertSame(
    114114            $expected_wrapper,
    115115            $actual,
  • trunk/tests/phpunit/tests/block-supports/wpRenderDimensionsSupport.php

    r57491 r58181  
    110110        $actual = wp_render_dimensions_support( $wrapper, $block );
    111111
    112         $this->assertEquals(
     112        $this->assertSame(
    113113            $expected_wrapper,
    114114            $actual,
Note: See TracChangeset for help on using the changeset viewer.