Skip to content

Commit a379d09

Browse files
Tests: Use assertTrue()/assertFalse() instead of assertSame() with booleans.
Using the dedicated boolean assertions clarifies intent and produces more descriptive failure messages. Follow-up to [51453]. Props Soean, mukesh27. See #64894. git-svn-id: https://develop.svn.wordpress.org/trunk@62969 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d1c6be6 commit a379d09

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

tests/phpunit/tests/blocks/wpBlockType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,9 @@ public function test_variations_callback_are_lazy_loaded() {
528528
)
529529
);
530530

531-
$this->assertSame( false, $callback_called, 'The callback should not be called before the variations are accessed.' );
531+
$this->assertFalse( $callback_called, 'The callback should not be called before the variations are accessed.' );
532532
$block_type->variations; // access the variations.
533-
$this->assertSame( true, $callback_called, 'The callback should be called when the variations are accessed.' );
533+
$this->assertTrue( $callback_called, 'The callback should be called when the variations are accessed.' );
534534
}
535535

536536
/**
@@ -555,7 +555,7 @@ public function test_variations_precedence_over_callback_post_registration() {
555555

556556
// If the variations are defined after registration but before first access, the callback should not override it.
557557
$this->assertSameSets( $test_variations, $block_type->get_variations(), 'Variations are same as variations set' );
558-
$this->assertSame( false, $callback_called, 'The callback was never called.' );
558+
$this->assertFalse( $callback_called, 'The callback was never called.' );
559559
}
560560

561561
/**
@@ -617,7 +617,7 @@ public function test_get_block_type_variations_filter_with_variation_callback()
617617

618618
$obtained_variations = $block_type->variations; // access the variations.
619619

620-
$this->assertSame( true, $callback_called, 'The callback should be called when the variations are accessed.' );
620+
$this->assertTrue( $callback_called, 'The callback should be called when the variations are accessed.' );
621621
$this->assertSameSets( $obtained_variations, $expected_variations, 'The variations obtained from the callback should be filtered.' );
622622
}
623623

tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public function test_wp_bind_handles_nested_bindings() {
454454
public function test_wp_bind_handles_true_value() {
455455
$html = '<div data-wp-bind--id="myPlugin::state.trueValue"></div>';
456456
list($p) = $this->process_directives( $html );
457-
$this->assertSame( true, $p->get_attribute( 'id' ) );
457+
$this->assertTrue( $p->get_attribute( 'id' ) );
458458
}
459459

460460
/**
@@ -467,7 +467,7 @@ public function test_wp_bind_handles_true_value() {
467467
public function test_wp_bind_ignores_unique_ids() {
468468
$html = '<div data-wp-bind--id="myPlugin::state.trueValue"></div>';
469469
list($p) = $this->process_directives( $html );
470-
$this->assertSame( true, $p->get_attribute( 'id' ) );
470+
$this->assertTrue( $p->get_attribute( 'id' ) );
471471

472472
$html = '<div data-wp-bind--id---unique-id="myPlugin::state.trueValue"></div>';
473473
list($p) = $this->process_directives( $html );

tests/phpunit/tests/rest-api/rest-post-meta-fields.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,7 @@ public function test_update_meta_with_unchanged_values_and_custom_authentication
23482348
$this->assertSame( 200, $response->get_status() );
23492349

23502350
$data = $response->get_data();
2351-
$this->assertSame( false, $data['meta']['authenticated'] );
2351+
$this->assertFalse( $data['meta']['authenticated'] );
23522352
}
23532353

23542354
/**

tests/phpunit/tests/rest-api/wpRestMenusController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public function test_update_item() {
316316
$data = $response->get_data();
317317
$this->assertSame( 'New Name', $data['name'] );
318318
$this->assertSame( 'New Description', $data['description'] );
319-
$this->assertSame( true, $data['auto_add'] );
319+
$this->assertTrue( $data['auto_add'] );
320320
$this->assertSame( 'new-name', $data['slug'] );
321321
$this->assertSame( 'just meta', $data['meta']['test_single_menu'] );
322322
$this->assertFalse( isset( $data['meta']['test_cat_meta'] ) );

0 commit comments

Comments
 (0)