Make WordPress Core

Changeset 58462


Ignore:
Timestamp:
06/23/2024 11:38:49 AM (3 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSame() in wp_get_block_css_selector() 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 [56058].

See #60705.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme/wpGetBlockCssSelector.php

    r56536 r58462  
    4848
    4949        $selector = wp_get_block_css_selector( $block_type );
    50         $this->assertEquals( '.wp-custom-block-class', $selector );
     50        $this->assertSame( '.wp-custom-block-class', $selector );
    5151    }
    5252
     
    6262
    6363        $selector = wp_get_block_css_selector( $block_type );
    64         $this->assertEquals( '.experimental-selector', $selector );
     64        $this->assertSame( '.experimental-selector', $selector );
    6565    }
    6666
     
    7676
    7777        $selector = wp_get_block_css_selector( $block_type );
    78         $this->assertEquals( '.wp-block-without-selectors-or-supports', $selector );
     78        $this->assertSame( '.wp-block-without-selectors-or-supports', $selector );
    7979    }
    8080
     
    9090
    9191        $selector = wp_get_block_css_selector( $block_type );
    92         $this->assertEquals( '.wp-block-test-without-selectors-or-supports', $selector );
     92        $this->assertSame( '.wp-block-test-without-selectors-or-supports', $selector );
    9393    }
    9494
     
    104104
    105105        $selector = wp_get_block_css_selector( $block_type, 'typography' );
    106         $this->assertEquals( '.typography', $selector );
     106        $this->assertSame( '.typography', $selector );
    107107    }
    108108
     
    118118
    119119        $selector = wp_get_block_css_selector( $block_type, 'typography' );
    120         $this->assertEquals( '.typography', $selector );
     120        $this->assertSame( '.typography', $selector );
    121121    }
    122122
     
    132132
    133133        $selector = wp_get_block_css_selector( $block_type, 'typography' );
    134         $this->assertEquals( null, $selector );
     134        $this->assertSame( null, $selector );
    135135    }
    136136
     
    146146
    147147        $selector = wp_get_block_css_selector( $block_type, 'typography', true );
    148         $this->assertEquals( '.wp-block-test-fallback-feature-selector', $selector );
     148        $this->assertSame( '.wp-block-test-fallback-feature-selector', $selector );
    149149    }
    150150
     
    160160
    161161        $selector = wp_get_block_css_selector( $block_type, 'typography', true );
    162         $this->assertEquals( '.fallback-root-selector', $selector );
     162        $this->assertSame( '.fallback-root-selector', $selector );
    163163    }
    164164
     
    178178
    179179        $selector = wp_get_block_css_selector( $block_type, 'typography' );
    180         $this->assertEquals( '.wp-block-test-experimental-feature-selector .experimental-typography', $selector );
     180        $this->assertSame( '.wp-block-test-experimental-feature-selector .experimental-typography', $selector );
    181181    }
    182182
     
    192192
    193193        $selector = wp_get_block_css_selector( $block_type, 'typography', true );
    194         $this->assertEquals( '.wp-block-test-fallback-feature-selector', $selector );
     194        $this->assertSame( '.wp-block-test-fallback-feature-selector', $selector );
    195195    }
    196196
     
    206206
    207207        $selector = wp_get_block_css_selector( $block_type, 'typography' );
    208         $this->assertEquals( null, $selector );
     208        $this->assertSame( null, $selector );
    209209    }
    210210
     
    228228        );
    229229
    230         $this->assertEquals( '.root .typography .text-decoration', $selector );
     230        $this->assertSame( '.root .typography .text-decoration', $selector );
    231231    }
    232232
     
    249249        );
    250250
    251         $this->assertEquals( '.root .typography', $selector );
     251        $this->assertSame( '.root .typography', $selector );
    252252    }
    253253
     
    263263
    264264        $selector = wp_get_block_css_selector( $block_type, array( 'typography', 'fontSize' ) );
    265         $this->assertEquals( null, $selector );
     265        $this->assertSame( null, $selector );
    266266    }
    267267
     
    281281            true
    282282        );
    283         $this->assertEquals( '.wp-block-test-fallback-subfeature-selector', $selector );
     283        $this->assertSame( '.wp-block-test-fallback-subfeature-selector', $selector );
    284284    }
    285285
     
    298298            array( 'typography', 'fontSize' )
    299299        );
    300         $this->assertEquals( null, $selector );
     300        $this->assertSame( null, $selector );
    301301    }
    302302
     
    312312
    313313        $selector = wp_get_block_css_selector( $block_type, array() );
    314         $this->assertEquals( null, $selector );
     314        $this->assertSame( null, $selector );
    315315
    316316        $selector = wp_get_block_css_selector( $block_type, '' );
    317         $this->assertEquals( null, $selector );
     317        $this->assertSame( null, $selector );
    318318    }
    319319
     
    329329
    330330        $selector = wp_get_block_css_selector( $block_type, 'typography' );
    331         $this->assertEquals( '.found', $selector );
     331        $this->assertSame( '.found', $selector );
    332332
    333333        $selector = wp_get_block_css_selector( $block_type, array( 'typography' ) );
    334         $this->assertEquals( '.found', $selector );
     334        $this->assertSame( '.found', $selector );
    335335    }
    336336
     
    348348
    349349        $selector = wp_get_block_css_selector( $block_type, 'typography.fontSize' );
    350         $this->assertEquals( '.found', $selector );
     350        $this->assertSame( '.found', $selector );
    351351
    352352        $selector = wp_get_block_css_selector( $block_type, array( 'typography', 'fontSize' ) );
    353         $this->assertEquals( '.found', $selector );
     353        $this->assertSame( '.found', $selector );
    354354    }
    355355}
Note: See TracChangeset for help on using the changeset viewer.