Skip to content

Commit c7db788

Browse files
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: [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization Writing PHP Tests: Naming and Organization]. Follow-up to [53076], [53085], [54497], [56046], [56614], [57246], [57491]. See #60705. git-svn-id: https://develop.svn.wordpress.org/trunk@58181 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d56791a commit c7db788

7 files changed

Lines changed: 13 additions & 13 deletions

File tree

tests/phpunit/tests/block-supports/border.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @covers ::wp_apply_border_support
66
*/
7-
class Test_Block_Supports_Border extends WP_UnitTestCase {
7+
class Tests_Block_Supports_Border extends WP_UnitTestCase {
88
/**
99
* @var string|null
1010
*/

tests/phpunit/tests/block-supports/layout.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @covers ::wp_restore_image_outer_container
1212
*/
13-
class Test_Block_Supports_Layout extends WP_UnitTestCase {
13+
class Tests_Block_Supports_Layout extends WP_UnitTestCase {
1414

1515
/**
1616
* Theme root directory.
@@ -310,7 +310,7 @@ public function data_layout_support_flag_renders_classnames_on_wrapper() {
310310
*/
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

316316
/**

tests/phpunit/tests/block-supports/shadow.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @covers ::wp_apply_shadow_support
66
*/
7-
class Test_Block_Supports_Shadow extends WP_UnitTestCase {
7+
class Tests_Block_Supports_Shadow extends WP_UnitTestCase {
88
/**
99
* @var string|null
1010
*/

tests/phpunit/tests/block-supports/spacing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @covers ::wp_apply_spacing_support
66
*/
7-
class Test_Block_Supports_Spacing extends WP_UnitTestCase {
7+
class Tests_Block_Supports_Spacing extends WP_UnitTestCase {
88
/**
99
* @var string|null
1010
*/

tests/phpunit/tests/block-supports/typography.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ public function data_generate_replace_inline_font_styles_with_fluid_values_fixtu
11181118
* @param mixed $expected An expected return value.
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

11241124
/**
@@ -1143,14 +1143,14 @@ public function data_valid_size_wp_get_typography_value_and_unit() {
11431143
'size: `"10"`' => array(
11441144
'raw_value' => '10',
11451145
'expected' => array(
1146-
'value' => 10,
1146+
'value' => 10.0,
11471147
'unit' => 'px',
11481148
),
11491149
),
11501150
'size: `11`' => array(
11511151
'raw_value' => 11,
11521152
'expected' => array(
1153-
'value' => 11,
1153+
'value' => 11.0,
11541154
'unit' => 'px',
11551155
),
11561156
),
@@ -1164,21 +1164,21 @@ public function data_valid_size_wp_get_typography_value_and_unit() {
11641164
'size: `"12rem"`' => array(
11651165
'raw_value' => '12rem',
11661166
'expected' => array(
1167-
'value' => 12,
1167+
'value' => 12.0,
11681168
'unit' => 'rem',
11691169
),
11701170
),
11711171
'size: `"12px"`' => array(
11721172
'raw_value' => '12px',
11731173
'expected' => array(
1174-
'value' => 12,
1174+
'value' => 12.0,
11751175
'unit' => 'px',
11761176
),
11771177
),
11781178
'size: `"12em"`' => array(
11791179
'raw_value' => '12em',
11801180
'expected' => array(
1181-
'value' => 12,
1181+
'value' => 12.0,
11821182
'unit' => 'em',
11831183
),
11841184
),

tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function test_background_block_support( $theme_name, $block_name, $backgr
110110

111111
$actual = wp_render_background_support( $wrapper, $block );
112112

113-
$this->assertEquals(
113+
$this->assertSame(
114114
$expected_wrapper,
115115
$actual,
116116
'Background block wrapper markup should be correct'

tests/phpunit/tests/block-supports/wpRenderDimensionsSupport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function test_dimensions_block_support( $theme_name, $block_name, $dimens
109109

110110
$actual = wp_render_dimensions_support( $wrapper, $block );
111111

112-
$this->assertEquals(
112+
$this->assertSame(
113113
$expected_wrapper,
114114
$actual,
115115
'Dimensions block wrapper markup should be correct'

0 commit comments

Comments
 (0)