Skip to content

Commit de2572b

Browse files
Tests: Use assertNull() instead of assertSame() with null.
Using the dedicated `assertNull()` assertion instead of `assertSame( null, $actual )` clarifies intent and produces more descriptive failure messages. Developed in WordPress#12818. Follow-up to r62969. Props Soean. See #64894. git-svn-id: https://develop.svn.wordpress.org/trunk@63161 602fd350-edb4-49c9-b593-d223f7449a82
1 parent cdc5934 commit de2572b

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎tests/phpunit/tests/functions/maybeSerialize.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public function test_deserialize_request_utility_filtered_iterator_objects( $val
222222
}
223223
$callback_value = $property->getValue( $new_value );
224224

225-
$this->assertSame( null, $callback_value );
225+
$this->assertNull( $callback_value );
226226
} else {
227227
$this->assertSame( $value->count(), unserialize( $serialized )->count() );
228228
}

‎tests/phpunit/tests/post/types.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ public function test_removing_autosave_support_removes_rest_api_controller() {
626626

627627
remove_post_type_support( 'foo', 'autosave' );
628628
$post_type_object = get_post_type_object( 'foo' );
629-
$this->assertSame( null, $post_type_object->get_autosave_rest_controller(), 'Autosave controller should be removed.' );
629+
$this->assertNull( $post_type_object->get_autosave_rest_controller(), 'Autosave controller should be removed.' );
630630
_unregister_post_type( 'foo' );
631631
}
632632

‎tests/phpunit/tests/post/wpAfterInsertPost.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function test_new_post_via_wp_insert_post() {
157157
)
158158
);
159159

160-
$this->assertSame( null, self::$passed_post_before_status );
160+
$this->assertNull( self::$passed_post_before_status );
161161
$this->assertSame( 'a new post', self::$passed_post_title );
162162
}
163163

@@ -197,7 +197,7 @@ public function test_new_post_via_rest_controller() {
197197
);
198198
rest_get_server()->dispatch( $request );
199199

200-
$this->assertSame( null, self::$passed_post_before_title );
200+
$this->assertNull( self::$passed_post_before_title );
201201
$this->assertSame( 'new title', self::$passed_post_title );
202202
}
203203

‎tests/phpunit/tests/rest-api/rest-settings-controller.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,6 @@ public function test_provides_setting_metadata_in_schema() {
794794
$this->assertSame( 'string', $title['type'] );
795795
$this->assertSame( 'Title', $title['title'] );
796796
$this->assertSame( 'Site title.', $title['description'] );
797-
$this->assertSame( null, $title['default'] );
797+
$this->assertNull( $title['default'] );
798798
}
799799
}

‎tests/phpunit/tests/theme/wpGetBlockCssSelector.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function test_no_feature_level_selector_via_selectors_api() {
131131
);
132132

133133
$selector = wp_get_block_css_selector( $block_type, 'typography' );
134-
$this->assertSame( null, $selector );
134+
$this->assertNull( $selector );
135135
}
136136

137137
/**
@@ -205,7 +205,7 @@ public function test_no_feature_selector_via_experimental_property() {
205205
);
206206

207207
$selector = wp_get_block_css_selector( $block_type, 'typography' );
208-
$this->assertSame( null, $selector );
208+
$this->assertNull( $selector );
209209
}
210210

211211
/**
@@ -262,7 +262,7 @@ public function test_no_subfeature_level_selector_via_selectors_api() {
262262
);
263263

264264
$selector = wp_get_block_css_selector( $block_type, array( 'typography', 'fontSize' ) );
265-
$this->assertSame( null, $selector );
265+
$this->assertNull( $selector );
266266
}
267267

268268
/**
@@ -297,7 +297,7 @@ public function test_no_subfeature_selector_via_experimental_property() {
297297
$block_type,
298298
array( 'typography', 'fontSize' )
299299
);
300-
$this->assertSame( null, $selector );
300+
$this->assertNull( $selector );
301301
}
302302

303303
/**
@@ -311,10 +311,10 @@ public function test_empty_target_returns_null() {
311311
);
312312

313313
$selector = wp_get_block_css_selector( $block_type, array() );
314-
$this->assertSame( null, $selector );
314+
$this->assertNull( $selector );
315315

316316
$selector = wp_get_block_css_selector( $block_type, '' );
317-
$this->assertSame( null, $selector );
317+
$this->assertNull( $selector );
318318
}
319319

320320
/**

0 commit comments

Comments
 (0)