mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 14:50:29 +00:00
Tests: Replace some occurrences of assertEquals() with assertSame().
This ensures that not only the return values match the expected results, but also that their type is the same. Props costdev, desrosj. See #55654. git-svn-id: https://develop.svn.wordpress.org/trunk@54402 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2533,10 +2533,10 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertSame( $default_value, $this->manager->post_value( $setting, $default_value ) );
|
||||
$this->assertSame( $default_value, $setting->post_value( $default_value ) );
|
||||
|
||||
$post_value = '42';
|
||||
$this->manager->set_post_value( 'numeric', $post_value );
|
||||
$this->assertEquals( $post_value, $this->manager->post_value( $setting, $default_value ) );
|
||||
$this->assertEquals( $post_value, $setting->post_value( $default_value ) );
|
||||
$post_value = 42;
|
||||
$this->manager->set_post_value( 'numeric', (string) $post_value );
|
||||
$this->assertSame( $post_value, $this->manager->post_value( $setting, $default_value ) );
|
||||
$this->assertSame( $post_value, $setting->post_value( $default_value ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -188,8 +188,6 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
|
||||
$count_customize_render_partials_after = has_action( 'customize_render_partials_after' );
|
||||
ob_start();
|
||||
try {
|
||||
$this->expected_partial_ids = array( 'foo' );
|
||||
@@ -200,8 +198,8 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
} catch ( WPDieException $e ) {
|
||||
$this->assertSame( '', $e->getMessage() );
|
||||
}
|
||||
$this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
|
||||
$this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
|
||||
$this->assertTrue( has_action( 'customize_render_partials_before' ) );
|
||||
$this->assertTrue( has_action( 'customize_render_partials_after' ) );
|
||||
$output = json_decode( ob_get_clean(), true );
|
||||
$this->assertSame( array( false ), $output['data']['contents']['foo'] );
|
||||
}
|
||||
@@ -326,8 +324,6 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
|
||||
$count_customize_render_partials_after = has_action( 'customize_render_partials_after' );
|
||||
ob_start();
|
||||
try {
|
||||
$this->expected_partial_ids = array( 'test_blogname' );
|
||||
@@ -338,8 +334,8 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
} catch ( WPDieException $e ) {
|
||||
$this->assertSame( '', $e->getMessage() );
|
||||
}
|
||||
$this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
|
||||
$this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
|
||||
$this->assertTrue( has_action( 'customize_render_partials_before' ) );
|
||||
$this->assertTrue( has_action( 'customize_render_partials_after' ) );
|
||||
$output = json_decode( ob_get_clean(), true );
|
||||
$this->assertSame( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_blogname'] );
|
||||
$this->assertArrayHasKey( 'setting_validities', $output['data'] );
|
||||
@@ -435,8 +431,6 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
|
||||
$count_customize_render_partials_after = has_action( 'customize_render_partials_after' );
|
||||
ob_start();
|
||||
try {
|
||||
$this->expected_partial_ids = array( 'test_dynamic_blogname' );
|
||||
@@ -447,8 +441,8 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
} catch ( WPDieException $e ) {
|
||||
$this->assertSame( '', $e->getMessage() );
|
||||
}
|
||||
$this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
|
||||
$this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
|
||||
$this->assertTrue( has_action( 'customize_render_partials_before' ) );
|
||||
$this->assertTrue( has_action( 'customize_render_partials_after' ) );
|
||||
$output = json_decode( ob_get_clean(), true );
|
||||
$this->assertSame( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_dynamic_blogname'] );
|
||||
}
|
||||
@@ -487,8 +481,6 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
|
||||
$count_customize_render_partials_after = has_action( 'customize_render_partials_after' );
|
||||
ob_start();
|
||||
try {
|
||||
$this->expected_partial_ids = array( 'test_blogname', 'test_blogdescription' );
|
||||
@@ -499,8 +491,8 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
} catch ( WPDieException $e ) {
|
||||
$this->assertSame( '', $e->getMessage() );
|
||||
}
|
||||
$this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
|
||||
$this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
|
||||
$this->assertTrue( has_action( 'customize_render_partials_before' ) );
|
||||
$this->assertTrue( has_action( 'customize_render_partials_after' ) );
|
||||
$output = json_decode( ob_get_clean(), true );
|
||||
$this->assertSame( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_blogname'] );
|
||||
$this->assertSame( array_fill( 0, 2, get_bloginfo( 'description', 'display' ) ), $output['data']['contents']['test_blogdescription'] );
|
||||
|
||||
Reference in New Issue
Block a user