Make WordPress Core


Ignore:
Timestamp:
07/23/2016 08:52:52 AM (8 years ago)
Author:
SergeyBiryukov
Message:

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

See #26284.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/getPageUri.php

    r37345 r38143  
    55 */
    66class Tests_Post_getPageUri extends WP_UnitTestCase {
     7
     8    /**
     9     * @ticket 22883
     10     */
     11    function test_get_page_uri_with_stdclass_post_object() {
     12        $post_id    = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
     13
     14        // Mimick an old stdClass post object, missing the ancestors field.
     15        $post_array = (object) get_post( $post_id, ARRAY_A );
     16        unset( $post_array->ancestors );
     17
     18        // Dummy assertion. If this test fails, it will actually error out on an E_WARNING.
     19        $this->assertEquals( 'get-page-uri-post-name', get_page_uri( $post_array ) );
     20    }
     21
     22    /**
     23     * @ticket 24491
     24     */
     25    function test_get_page_uri_with_nonexistent_post() {
     26        global $wpdb;
     27        $post_id = $wpdb->get_var( "SELECT MAX(ID) FROM $wpdb->posts" ) + 1;
     28        $this->assertFalse( get_page_uri( $post_id ) );
     29    }
     30
     31    /**
     32     * @ticket 15963
     33     */
     34    function test_get_post_uri_check_orphan() {
     35        $parent_id = self::factory()->post->create( array( 'post_name' => 'parent' ) );
     36        $child_id = self::factory()->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) );
     37
     38        // check the parent for good measure
     39        $this->assertEquals( 'parent', get_page_uri( $parent_id ) );
     40
     41        // try the child normally
     42        $this->assertEquals( 'parent/child', get_page_uri( $child_id ) );
     43
     44        // now delete the parent from the database and check
     45        wp_delete_post( $parent_id, true );
     46        $this->assertEquals( 'child', get_page_uri( $child_id ) );
     47    }
    748
    849    function test_get_page_uri_without_argument() {
Note: See TracChangeset for help on using the changeset viewer.