Unit Tests: Move `get_page_uri()` tests to `post/getPageUri.php`, added in [37345].

See #26284.

git-svn-id: https://develop.svn.wordpress.org/trunk@38143 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2016-07-23 08:52:52 +00:00
parent 65ba451f5b
commit 4f23ce8545
2 changed files with 41 additions and 41 deletions

View File

@ -638,47 +638,6 @@ class Tests_Post extends WP_UnitTestCase {
kses_remove_filters();
}
/**
* @ticket 22883
*/
function test_get_page_uri_with_stdclass_post_object() {
$post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
// Mimick an old stdClass post object, missing the ancestors field.
$post_array = (object) get_post( $post_id, ARRAY_A );
unset( $post_array->ancestors );
// Dummy assertion. If this test fails, it will actually error out on an E_WARNING.
$this->assertEquals( 'get-page-uri-post-name', get_page_uri( $post_array ) );
}
/**
* @ticket 24491
*/
function test_get_page_uri_with_nonexistent_post() {
global $wpdb;
$post_id = $wpdb->get_var( "SELECT MAX(ID) FROM $wpdb->posts" ) + 1;
$this->assertFalse( get_page_uri( $post_id ) );
}
/**
* @ticket 15963
*/
function test_get_post_uri_check_orphan() {
$parent_id = self::factory()->post->create( array( 'post_name' => 'parent' ) );
$child_id = self::factory()->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) );
// check the parent for good measure
$this->assertEquals( 'parent', get_page_uri( $parent_id ) );
// try the child normally
$this->assertEquals( 'parent/child', get_page_uri( $child_id ) );
// now delete the parent from the database and check
wp_delete_post( $parent_id, true );
$this->assertEquals( 'child', get_page_uri( $child_id ) );
}
/**
* @ticket 23708
*/

View File

@ -5,6 +5,47 @@
*/
class Tests_Post_getPageUri extends WP_UnitTestCase {
/**
* @ticket 22883
*/
function test_get_page_uri_with_stdclass_post_object() {
$post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
// Mimick an old stdClass post object, missing the ancestors field.
$post_array = (object) get_post( $post_id, ARRAY_A );
unset( $post_array->ancestors );
// Dummy assertion. If this test fails, it will actually error out on an E_WARNING.
$this->assertEquals( 'get-page-uri-post-name', get_page_uri( $post_array ) );
}
/**
* @ticket 24491
*/
function test_get_page_uri_with_nonexistent_post() {
global $wpdb;
$post_id = $wpdb->get_var( "SELECT MAX(ID) FROM $wpdb->posts" ) + 1;
$this->assertFalse( get_page_uri( $post_id ) );
}
/**
* @ticket 15963
*/
function test_get_post_uri_check_orphan() {
$parent_id = self::factory()->post->create( array( 'post_name' => 'parent' ) );
$child_id = self::factory()->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) );
// check the parent for good measure
$this->assertEquals( 'parent', get_page_uri( $parent_id ) );
// try the child normally
$this->assertEquals( 'parent/child', get_page_uri( $child_id ) );
// now delete the parent from the database and check
wp_delete_post( $parent_id, true );
$this->assertEquals( 'child', get_page_uri( $child_id ) );
}
function test_get_page_uri_without_argument() {
$post_id = self::factory()->post->create(array(
'post_title' => 'Blood Orange announces summer tour dates',