Tests: First pass at using assertSame() instead of assertEquals() in most of the unit 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.

Props johnbillion, jrf, SergeyBiryukov.
See #38266.

git-svn-id: https://develop.svn.wordpress.org/trunk@48937 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-09-02 00:35:36 +00:00
parent ba7c6a2d5f
commit 164b22cf6a
426 changed files with 7959 additions and 7949 deletions
+129 -129
View File
@@ -85,25 +85,25 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post and make sure it matches.
$out = get_post( $id );
$this->assertEquals( $post['post_content'], $out->post_content );
$this->assertEquals( $post['post_title'], $out->post_title );
$this->assertEquals( $post['post_status'], $out->post_status );
$this->assertSame( $post['post_content'], $out->post_content );
$this->assertSame( $post['post_title'], $out->post_title );
$this->assertSame( $post['post_status'], $out->post_status );
$this->assertEquals( $post['post_author'], $out->post_author );
// Test cache state.
$pcache = wp_cache_get( $id, 'posts' );
$this->assertInstanceOf( 'stdClass', $pcache );
$this->assertEquals( $id, $pcache->ID );
$this->assertSame( $id, $pcache->ID );
update_object_term_cache( $id, $post_type );
$tcache = wp_cache_get( $id, 'post_tag_relationships' );
$this->assertInternalType( 'array', $tcache );
$this->assertEquals( 2, count( $tcache ) );
$this->assertSame( 2, count( $tcache ) );
$tcache = wp_cache_get( $id, 'ctax_relationships' );
if ( 'cpt' === $post_type ) {
$this->assertInternalType( 'array', $tcache );
$this->assertEquals( 2, count( $tcache ) );
$this->assertSame( 2, count( $tcache ) );
} else {
$this->assertFalse( $tcache );
}
@@ -141,14 +141,14 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post and make sure it matches.
$out = get_post( $id );
$this->assertEquals( $post['post_content'], $out->post_content );
$this->assertEquals( $post['post_title'], $out->post_title );
$this->assertEquals( 'future', $out->post_status );
$this->assertSame( $post['post_content'], $out->post_content );
$this->assertSame( $post['post_title'], $out->post_title );
$this->assertSame( 'future', $out->post_status );
$this->assertEquals( $post['post_author'], $out->post_author );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( $post['post_date'], $out->post_date );
// There should be a publish_future_post hook scheduled on the future date.
$this->assertEquals( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertSame( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
}
/**
@@ -173,11 +173,11 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post and make sure has the correct date and status.
$out = get_post( $id );
$this->assertEquals( 'future', $out->post_status );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( 'future', $out->post_status );
$this->assertSame( $post['post_date'], $out->post_date );
// Check that there's a publish_future_post job scheduled at the right time.
$this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
// Now save it again with a date further in the future.
@@ -188,11 +188,11 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post again and make sure it has the new post_date.
$out = get_post( $id );
$this->assertEquals( 'future', $out->post_status );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( 'future', $out->post_status );
$this->assertSame( $post['post_date'], $out->post_date );
// And the correct date on the cron job.
$this->assertEquals( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertSame( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
}
/**
@@ -218,11 +218,11 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post and make sure has the correct date and status.
$out = get_post( $id );
$this->assertEquals( 'future', $out->post_status );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( 'future', $out->post_status );
$this->assertSame( $post['post_date'], $out->post_date );
// Check that there's a publish_future_post job scheduled at the right time.
$this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
// Now save it again with a date further in the future.
@@ -233,11 +233,11 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post again and make sure it has the new post_date.
$out = get_post( $id );
$this->assertEquals( 'future', $out->post_status );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( 'future', $out->post_status );
$this->assertSame( $post['post_date'], $out->post_date );
// And the correct date on the cron job.
$this->assertEquals( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertSame( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
}
/**
@@ -264,14 +264,14 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post and make sure it matches.
$out = get_post( $id );
$this->assertEquals( $post['post_content'], $out->post_content );
$this->assertEquals( $post['post_title'], $out->post_title );
$this->assertEquals( 'draft', $out->post_status );
$this->assertSame( $post['post_content'], $out->post_content );
$this->assertSame( $post['post_title'], $out->post_title );
$this->assertSame( 'draft', $out->post_status );
$this->assertEquals( $post['post_author'], $out->post_author );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( $post['post_date'], $out->post_date );
// There should be a publish_future_post hook scheduled on the future date.
$this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
}
@@ -295,11 +295,11 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post and make sure has the correct date and status.
$out = get_post( $id );
$this->assertEquals( 'future', $out->post_status );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( 'future', $out->post_status );
$this->assertSame( $post['post_date'], $out->post_date );
// Check that there's a publish_future_post job scheduled at the right time.
$this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
// Now save it again with status set to draft.
@@ -309,11 +309,11 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post again and make sure it has the new post_date.
$out = get_post( $id );
$this->assertEquals( 'draft', $out->post_status );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( 'draft', $out->post_status );
$this->assertSame( $post['post_date'], $out->post_date );
// And the correct date on the cron job.
$this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
}
/**
@@ -339,11 +339,11 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post and make sure has the correct date and status.
$out = get_post( $id );
$this->assertEquals( 'future', $out->post_status );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( 'future', $out->post_status );
$this->assertSame( $post['post_date'], $out->post_date );
// Check that there's a publish_future_post job scheduled at the right time.
$this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
// Now save it again with status changed.
@@ -353,11 +353,11 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post again and make sure it has the new post_date.
$out = get_post( $id );
$this->assertEquals( $status, $out->post_status );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( $status, $out->post_status );
$this->assertSame( $post['post_date'], $out->post_date );
// And the correct date on the cron job.
$this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
}
}
@@ -385,14 +385,14 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post and make sure it matches.
$out = get_post( $id );
$this->assertEquals( $post['post_content'], $out->post_content );
$this->assertEquals( $post['post_title'], $out->post_title );
$this->assertEquals( 'private', $out->post_status );
$this->assertSame( $post['post_content'], $out->post_content );
$this->assertSame( $post['post_title'], $out->post_title );
$this->assertSame( 'private', $out->post_status );
$this->assertEquals( $post['post_author'], $out->post_author );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( $post['post_date'], $out->post_date );
// There should be a publish_future_post hook scheduled on the future date.
$this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
}
/**
@@ -412,10 +412,10 @@ class Tests_Post extends WP_UnitTestCase {
// Test both return paths with or without WP_Error.
$insert_post = wp_insert_post( $post, true );
$this->assertWPError( $insert_post );
$this->assertEquals( 'invalid_date', $insert_post->get_error_code() );
$this->assertSame( 'invalid_date', $insert_post->get_error_code() );
$insert_post = wp_insert_post( $post );
$this->assertEquals( 0, $insert_post );
$this->assertSame( 0, $insert_post );
}
/**
@@ -438,11 +438,11 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post and make sure has the correct date and status.
$out = get_post( $id );
$this->assertEquals( 'future', $out->post_status );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( 'future', $out->post_status );
$this->assertSame( $post['post_date'], $out->post_date );
// Check that there's a publish_future_post job scheduled at the right time.
$this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
// Now save it again with status set to draft.
@@ -452,11 +452,11 @@ class Tests_Post extends WP_UnitTestCase {
// Fetch the post again and make sure it has the new post_date.
$out = get_post( $id );
$this->assertEquals( 'private', $out->post_status );
$this->assertEquals( $post['post_date'], $out->post_date );
$this->assertSame( 'private', $out->post_status );
$this->assertSame( $post['post_date'], $out->post_date );
// And the correct date on the cron job.
$this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
}
/**
@@ -478,7 +478,7 @@ class Tests_Post extends WP_UnitTestCase {
$this->set_permalink_structure();
$this->assertEquals( "$p-2", $post->post_name );
$this->assertSame( "$p-2", $post->post_name );
}
/**
@@ -518,8 +518,8 @@ class Tests_Post extends WP_UnitTestCase {
)
);
$this->assertEquals( 'world', get_post_meta( $post_id, 'hello', true ) );
$this->assertEquals( 'bar', get_post_meta( $post_id, 'foo', true ) );
$this->assertSame( 'world', get_post_meta( $post_id, 'hello', true ) );
$this->assertSame( 'bar', get_post_meta( $post_id, 'foo', true ) );
}
/**
@@ -543,7 +543,7 @@ class Tests_Post extends WP_UnitTestCase {
$this->post_ids[] = $id;
// Check that there's a publish_future_post job scheduled at the right time.
$this->assertEquals( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
$this->assertSame( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
// Now delete the post and make sure the cron entry is removed.
wp_delete_post( $id );
@@ -576,19 +576,19 @@ class Tests_Post extends WP_UnitTestCase {
$plink = get_permalink( $id );
// Permalink should include the post ID at the end.
$this->assertEquals( get_option( 'siteurl' ) . '/2007/10/31/' . $id . '/', $plink );
$this->assertSame( get_option( 'siteurl' ) . '/2007/10/31/' . $id . '/', $plink );
}
function test_wp_publish_post() {
$draft_id = self::factory()->post->create( array( 'post_status' => 'draft' ) );
$post = get_post( $draft_id );
$this->assertEquals( 'draft', $post->post_status );
$this->assertSame( 'draft', $post->post_status );
wp_publish_post( $draft_id );
$post = get_post( $draft_id );
$this->assertEquals( 'publish', $post->post_status );
$this->assertSame( 'publish', $post->post_status );
}
/**
@@ -604,14 +604,14 @@ class Tests_Post extends WP_UnitTestCase {
);
$post = get_post( $post_id );
$this->assertEquals( 'future', $post->post_status );
$this->assertEquals( $future_date, $post->post_date );
$this->assertSame( 'future', $post->post_status );
$this->assertSame( $future_date, $post->post_date );
wp_publish_post( $post_id );
$post = get_post( $post_id );
$this->assertEquals( 'publish', $post->post_status );
$this->assertEquals( $future_date, $post->post_date );
$this->assertSame( 'publish', $post->post_status );
$this->assertSame( $future_date, $post->post_date );
}
/**
@@ -626,8 +626,8 @@ class Tests_Post extends WP_UnitTestCase {
);
$post = get_post( $post_id );
$this->assertEquals( 'publish', $post->post_status );
$this->assertEquals( $future_date, $post->post_date );
$this->assertSame( 'publish', $post->post_status );
$this->assertSame( $future_date, $post->post_date );
}
/**
@@ -638,8 +638,8 @@ class Tests_Post extends WP_UnitTestCase {
$post_id = wp_insert_post( array( 'post_title' => '<script>Test</script>' ) );
$post = get_post( $post_id );
$this->assertEquals( '<script>Test</script>', $post->post_title );
$this->assertEquals( 'draft', $post->post_status );
$this->assertSame( '<script>Test</script>', $post->post_title );
$this->assertSame( 'draft', $post->post_status );
kses_init_filters();
@@ -650,7 +650,7 @@ class Tests_Post extends WP_UnitTestCase {
)
);
$post = get_post( $post->ID );
$this->assertEquals( 'Test', $post->post_title );
$this->assertSame( 'Test', $post->post_title );
kses_remove_filters();
}
@@ -663,14 +663,14 @@ class Tests_Post extends WP_UnitTestCase {
$post_id = wp_insert_post( array( 'post_title' => '<script>Test</script>' ) );
$post = get_post( $post_id );
$this->assertEquals( '<script>Test</script>', $post->post_title );
$this->assertEquals( 'draft', $post->post_status );
$this->assertSame( '<script>Test</script>', $post->post_title );
$this->assertSame( 'draft', $post->post_status );
kses_init_filters();
wp_publish_post( $post->ID );
$post = get_post( $post->ID );
$this->assertEquals( '<script>Test</script>', $post->post_title );
$this->assertSame( '<script>Test</script>', $post->post_title );
kses_remove_filters();
}
@@ -682,7 +682,7 @@ class Tests_Post extends WP_UnitTestCase {
global $post;
$parent_id = self::factory()->post->create();
$post = self::factory()->post->create_and_get( array( 'post_parent' => $parent_id ) );
$this->assertEquals( array( $parent_id ), get_post_ancestors( 0 ) );
$this->assertSame( array( $parent_id ), get_post_ancestors( 0 ) );
}
/**
@@ -694,8 +694,8 @@ class Tests_Post extends WP_UnitTestCase {
$post['ID'] = 123456789;
$this->assertEquals( 0, wp_insert_post( $post ) );
$this->assertEquals( 0, wp_update_post( $post ) );
$this->assertSame( 0, wp_insert_post( $post ) );
$this->assertSame( 0, wp_update_post( $post ) );
$this->assertInstanceOf( 'WP_Error', wp_insert_post( $post, true ) );
$this->assertInstanceOf( 'WP_Error', wp_update_post( $post, true ) );
@@ -707,10 +707,10 @@ class Tests_Post extends WP_UnitTestCase {
$post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 0, $multipage );
$this->assertSame( 0, $multipage );
$this->assertCount( 1, $pages );
$this->assertEquals( 1, $numpages );
$this->assertEquals( array( 'Page 0' ), $pages );
$this->assertSame( 1, $numpages );
$this->assertSame( array( 'Page 0' ), $pages );
}
function test_parse_post_content_multi_page() {
@@ -718,10 +718,10 @@ class Tests_Post extends WP_UnitTestCase {
$post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 1, $multipage );
$this->assertSame( 1, $multipage );
$this->assertCount( 4, $pages );
$this->assertEquals( 4, $numpages );
$this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages );
$this->assertSame( 4, $numpages );
$this->assertSame( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages );
}
function test_parse_post_content_remaining_single_page() {
@@ -729,10 +729,10 @@ class Tests_Post extends WP_UnitTestCase {
$post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 0, $multipage );
$this->assertSame( 0, $multipage );
$this->assertCount( 1, $pages );
$this->assertEquals( 1, $numpages );
$this->assertEquals( array( 'Page 0' ), $pages );
$this->assertSame( 1, $numpages );
$this->assertSame( array( 'Page 0' ), $pages );
}
function test_parse_post_content_remaining_multi_page() {
@@ -740,10 +740,10 @@ class Tests_Post extends WP_UnitTestCase {
$post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 1, $multipage );
$this->assertSame( 1, $multipage );
$this->assertCount( 4, $pages );
$this->assertEquals( 4, $numpages );
$this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages );
$this->assertSame( 4, $numpages );
$this->assertSame( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages );
}
/**
@@ -754,10 +754,10 @@ class Tests_Post extends WP_UnitTestCase {
$post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 1, $multipage );
$this->assertSame( 1, $multipage );
$this->assertCount( 4, $pages );
$this->assertEquals( 4, $numpages );
$this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages );
$this->assertSame( 4, $numpages );
$this->assertSame( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages );
}
/**
@@ -768,10 +768,10 @@ class Tests_Post extends WP_UnitTestCase {
$post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 0, $multipage );
$this->assertSame( 0, $multipage );
$this->assertCount( 1, $pages );
$this->assertEquals( 1, $numpages );
$this->assertEquals( array( 'Page 0' ), $pages );
$this->assertSame( 1, $numpages );
$this->assertSame( array( 'Page 0' ), $pages );
}
/**
@@ -797,7 +797,7 @@ class Tests_Post extends WP_UnitTestCase {
$post = get_post( $insert_post_id );
$this->assertEquals( $post->post_author, self::$editor_id );
$this->assertEquals( $post->post_title, $title );
$this->assertSame( $post->post_title, $title );
}
/**
@@ -852,7 +852,7 @@ class Tests_Post extends WP_UnitTestCase {
$_post['post_status'] = 'draft';
wp_insert_post( $_post );
$post = get_post( $post_ids[ $key ] );
$this->assertEquals( 'draft', $post->post_status );
$this->assertSame( 'draft', $post->post_status );
$this->assertNotEquals( 'publish', $post->post_status );
$after_draft_counts = wp_count_posts();
@@ -870,7 +870,7 @@ class Tests_Post extends WP_UnitTestCase {
wp_trash_post( $post_ids[ $key ] );
$post = get_post( $post_ids[ $key ] );
$this->assertEquals( 'trash', $post->post_status );
$this->assertSame( 'trash', $post->post_status );
$this->assertNotEquals( 'publish', $post->post_status );
$after_trash_counts = wp_count_posts();
@@ -892,7 +892,7 @@ class Tests_Post extends WP_UnitTestCase {
$counts = wp_count_posts();
$this->assertTrue( isset( $counts->test ) );
$this->assertEquals( 0, $counts->test );
$this->assertSame( 0, $counts->test );
}
/**
@@ -960,7 +960,7 @@ class Tests_Post extends WP_UnitTestCase {
$post = get_post( $post_id );
foreach ( $expected as $field => $value ) {
$this->assertEquals( $value, $post->$field );
$this->assertSame( $value, $post->$field );
}
}
@@ -978,8 +978,8 @@ class Tests_Post extends WP_UnitTestCase {
);
$post = get_post( $post_id );
$this->assertEquals( 'open', $post->comment_status );
$this->assertEquals( 'open', $post->ping_status );
$this->assertSame( 'open', $post->comment_status );
$this->assertSame( 'open', $post->ping_status );
}
/**
@@ -997,8 +997,8 @@ class Tests_Post extends WP_UnitTestCase {
);
$post = get_post( $post_id );
$this->assertEquals( 'closed', $post->comment_status );
$this->assertEquals( 'closed', $post->ping_status );
$this->assertSame( 'closed', $post->comment_status );
$this->assertSame( 'closed', $post->ping_status );
}
/**
@@ -1018,8 +1018,8 @@ class Tests_Post extends WP_UnitTestCase {
);
$post = get_post( $post_id );
$this->assertEquals( 'open', $post->comment_status );
$this->assertEquals( 'open', $post->ping_status );
$this->assertSame( 'open', $post->comment_status );
$this->assertSame( 'open', $post->ping_status );
_unregister_post_type( $post_type );
}
@@ -1040,8 +1040,8 @@ class Tests_Post extends WP_UnitTestCase {
);
$post = get_post( $post_id );
$this->assertEquals( 'closed', $post->comment_status );
$this->assertEquals( 'closed', $post->ping_status );
$this->assertSame( 'closed', $post->comment_status );
$this->assertSame( 'closed', $post->ping_status );
_unregister_post_type( $post_type );
}
@@ -1079,8 +1079,8 @@ class Tests_Post extends WP_UnitTestCase {
// Make sure it's still sticky.
$saved_post = get_post( $post->ID );
$this->assertTrue( is_sticky( $saved_post->ID ) );
$this->assertEquals( 'Updated', $saved_post->post_title );
$this->assertEquals( 'Updated', $saved_post->post_content );
$this->assertSame( 'Updated', $saved_post->post_title );
$this->assertSame( 'Updated', $saved_post->post_content );
}
/**
@@ -1120,8 +1120,8 @@ class Tests_Post extends WP_UnitTestCase {
// Make sure it's still sticky.
$saved_post = get_post( $post->ID );
$this->assertTrue( is_sticky( $saved_post->ID ) );
$this->assertEquals( 'Updated', $saved_post->post_title );
$this->assertEquals( 'Updated', $saved_post->post_content );
$this->assertSame( 'Updated', $saved_post->post_title );
$this->assertSame( 'Updated', $saved_post->post_content );
}
/**
@@ -1147,8 +1147,8 @@ class Tests_Post extends WP_UnitTestCase {
remove_action( 'post_stuck', array( $a1, 'action' ) );
remove_action( 'post_unstuck', array( $a2, 'action' ) );
$this->assertEquals( 1, $a1->get_call_count() );
$this->assertEquals( 1, $a2->get_call_count() );
$this->assertSame( 1, $a1->get_call_count() );
$this->assertSame( 1, $a2->get_call_count() );
}
/**
@@ -1174,7 +1174,7 @@ class Tests_Post extends WP_UnitTestCase {
$updated_post = get_post( $post_id );
// Ensure changing the post_title didn't modify the post_name.
$this->assertEquals( 'stuff', $updated_post->post_name );
$this->assertSame( 'stuff', $updated_post->post_name );
}
/**
@@ -1212,11 +1212,11 @@ class Tests_Post extends WP_UnitTestCase {
$out = get_post( $id );
$this->assertEquals( $post['post_content'], $out->post_content );
$this->assertEquals( $post['post_title'], $out->post_title );
$this->assertSame( $post['post_content'], $out->post_content );
$this->assertSame( $post['post_title'], $out->post_title );
$this->assertEquals( $post['post_author'], $out->post_author );
$this->assertEquals( get_date_from_gmt( $post['post_date_gmt'] ), $out->post_date );
$this->assertEquals( $post['post_date_gmt'], $out->post_date_gmt );
$this->assertSame( get_date_from_gmt( $post['post_date_gmt'] ), $out->post_date );
$this->assertSame( $post['post_date_gmt'], $out->post_date_gmt );
}
function test_wp_delete_post_reassign_hierarchical_post_type() {
@@ -1233,11 +1233,11 @@ class Tests_Post extends WP_UnitTestCase {
'post_parent' => $parent_page_id,
)
);
$this->assertEquals( $parent_page_id, get_post( $page_id )->post_parent );
$this->assertSame( $parent_page_id, get_post( $page_id )->post_parent );
wp_delete_post( $parent_page_id, true );
$this->assertEquals( $grandparent_page_id, get_post( $page_id )->post_parent );
$this->assertSame( $grandparent_page_id, get_post( $page_id )->post_parent );
wp_delete_post( $grandparent_page_id, true );
$this->assertEquals( 0, get_post( $page_id )->post_parent );
$this->assertSame( 0, get_post( $page_id )->post_parent );
}
/**
@@ -1248,7 +1248,7 @@ class Tests_Post extends WP_UnitTestCase {
*/
function test_wp_insert_post_for_customize_changeset_should_not_drop_post_name() {
$this->assertEquals( 10, has_filter( 'wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data' ) );
$this->assertSame( 10, has_filter( 'wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data' ) );
$changeset_data = array(
'blogname' => array(
@@ -1266,8 +1266,8 @@ class Tests_Post extends WP_UnitTestCase {
'post_content' => wp_json_encode( $changeset_data ),
)
);
$this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected lower-case UUID4 to be inserted.' );
$this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
$this->assertSame( $uuid, get_post( $post_id )->post_name, 'Expected lower-case UUID4 to be inserted.' );
$this->assertSame( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
$changeset_data['blogname']['value'] = 'Hola Mundo';
wp_update_post(
@@ -1277,8 +1277,8 @@ class Tests_Post extends WP_UnitTestCase {
'post_content' => wp_json_encode( $changeset_data ),
)
);
$this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for drafts.' );
$this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
$this->assertSame( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for drafts.' );
$this->assertSame( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
$changeset_data['blogname']['value'] = 'Hallo Welt';
wp_update_post(
@@ -1288,8 +1288,8 @@ class Tests_Post extends WP_UnitTestCase {
'post_content' => wp_json_encode( $changeset_data ),
)
);
$this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for pending.' );
$this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
$this->assertSame( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for pending.' );
$this->assertSame( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
}
/**
@@ -1310,7 +1310,7 @@ class Tests_Post extends WP_UnitTestCase {
)
);
$post = get_post( $post_id );
$this->assertEquals( 'override-slug-' . $post->post_type, $post->post_name );
$this->assertSame( 'override-slug-' . $post->post_type, $post->post_name );
remove_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 );
}
@@ -1334,7 +1334,7 @@ class Tests_Post extends WP_UnitTestCase {
);
$post = get_post( $post_id );
self::assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
self::assertSame( '0000-00-00 00:00:00', $post->post_date_gmt );
}
/**