mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Tests: Use assertSame() in some newly introduced 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 [55859], [56380], [56802], [57115], [57129], [57185]. See #59655. git-svn-id: https://develop.svn.wordpress.org/trunk@57244 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -52,7 +52,7 @@ class Tests_Ajax_wpAjaxImageEditor extends WP_Ajax_UnitTestCase {
|
||||
$ret = wp_save_image( $id );
|
||||
|
||||
$this->assertObjectHasProperty( 'error', $ret );
|
||||
$this->assertEquals( 'Images cannot be scaled to a size larger than the original.', $ret->error );
|
||||
$this->assertSame( 'Images cannot be scaled to a size larger than the original.', $ret->error );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -110,7 +110,7 @@ class Tests_Ajax_wpAjaxInlineSave extends WP_Ajax_UnitTestCase {
|
||||
|
||||
$this->assertSame( 'draft', $post->post_status );
|
||||
|
||||
$this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
|
||||
$this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt );
|
||||
|
||||
// Set up a request.
|
||||
$_POST['_inline_edit'] = wp_create_nonce( 'inlineeditnonce' );
|
||||
@@ -142,7 +142,7 @@ class Tests_Ajax_wpAjaxInlineSave extends WP_Ajax_UnitTestCase {
|
||||
|
||||
$post_date = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $_POST['aa'], $_POST['mm'], $_POST['jj'], $_POST['hh'], $_POST['mn'], $_POST['ss'] );
|
||||
|
||||
$this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
|
||||
$this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +167,7 @@ class Tests_Ajax_wpAjaxInlineSave extends WP_Ajax_UnitTestCase {
|
||||
|
||||
$this->assertSame( 'draft', $post->post_status );
|
||||
|
||||
$this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
|
||||
$this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt );
|
||||
|
||||
// Set up a request.
|
||||
$_POST['_inline_edit'] = wp_create_nonce( 'inlineeditnonce' );
|
||||
@@ -197,6 +197,6 @@ class Tests_Ajax_wpAjaxInlineSave extends WP_Ajax_UnitTestCase {
|
||||
|
||||
$post = get_post( $post->ID );
|
||||
|
||||
$this->assertEquals( '2020-09-11 19:20:11', $post->post_date_gmt );
|
||||
$this->assertSame( '2020-09-11 19:20:11', $post->post_date_gmt );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3366,7 +3366,7 @@ HTML
|
||||
|
||||
wp_default_packages_vendor( $wp_scripts );
|
||||
|
||||
$this->assertEquals( $package_json[ $script ], $wp_scripts->query( $script, 'registered' )->ver );
|
||||
$this->assertSame( $package_json[ $script ], $wp_scripts->query( $script, 'registered' )->ver );
|
||||
}
|
||||
|
||||
public function data_wp_default_packages_vendor() {
|
||||
|
||||
@@ -35,7 +35,7 @@ class Tests_HtmlApi_WpHtmlProcessorSemanticRules extends WP_UnitTestCase {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
$tag_name,
|
||||
$processor->get_tag(),
|
||||
"Expected to find {$tag_name} but found {$processor->get_tag()} instead."
|
||||
@@ -125,7 +125,7 @@ class Tests_HtmlApi_WpHtmlProcessorSemanticRules extends WP_UnitTestCase {
|
||||
$p = WP_HTML_Processor::create_fragment( '<div>Test</button></div>' );
|
||||
|
||||
$p->step();
|
||||
$this->assertEquals( 'DIV', $p->get_tag(), 'Did not stop at initial DIV tag.' );
|
||||
$this->assertSame( 'DIV', $p->get_tag(), 'Did not stop at initial DIV tag.' );
|
||||
$this->assertFalse( $p->is_tag_closer(), 'Did not find that initial DIV tag is an opener.' );
|
||||
|
||||
/*
|
||||
@@ -133,7 +133,7 @@ class Tests_HtmlApi_WpHtmlProcessorSemanticRules extends WP_UnitTestCase {
|
||||
* It should be ignored as there's no BUTTON to close.
|
||||
*/
|
||||
$this->assertTrue( $p->step(), 'Found no further tags when it should have found the closing DIV' );
|
||||
$this->assertEquals( 'DIV', $p->get_tag(), "Did not skip unexpected BUTTON; stopped at {$p->get_tag()}." );
|
||||
$this->assertSame( 'DIV', $p->get_tag(), "Did not skip unexpected BUTTON; stopped at {$p->get_tag()}." );
|
||||
$this->assertTrue( $p->is_tag_closer(), 'Did not find that the terminal DIV tag is a closer.' );
|
||||
}
|
||||
|
||||
|
||||
@@ -1259,8 +1259,8 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
// Cleanup.
|
||||
switch_theme( $old_theme->get_stylesheet() );
|
||||
|
||||
$this->assertEquals( $old_root . '/test', $path1, 'The original stylesheet path is not correct' );
|
||||
$this->assertEquals( $new_root . '/test', $path2, 'The new stylesheet path is not correct' );
|
||||
$this->assertSame( $old_root . '/test', $path1, 'The original stylesheet path is not correct' );
|
||||
$this->assertSame( $new_root . '/test', $path2, 'The new stylesheet path is not correct' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1302,7 +1302,7 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
// Cleanup.
|
||||
switch_theme( $old_theme->get_stylesheet() );
|
||||
|
||||
$this->assertEquals( $old_root . '/test-parent', $path1, 'The original template path is not correct' );
|
||||
$this->assertEquals( $new_root . '/test-parent', $path2, 'The new template path is not correct' );
|
||||
$this->assertSame( $old_root . '/test-parent', $path1, 'The original template path is not correct' );
|
||||
$this->assertSame( $new_root . '/test-parent', $path2, 'The new template path is not correct' );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user