Make WordPress Core

Ticket #22223: 22223-ut.2.diff

File 22223-ut.2.diff, 966 bytes (added by ryan, 14 years ago)
  • tests/post/objects.php

     
    185185                $this->assertInternalType( 'array', $post['ancestors'] );
    186186                $this->assertEquals( 'raw', $post['filter'] );
    187187        }
     188
     189        function test_get_post_cache() {
     190                global $wpdb;
     191
     192                $id = $this->factory->post->create();
     193                wp_cache_delete( $id, 'posts' );
     194
     195                // get_post( stdClass ) should not prime the cache
     196                $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id ) );
     197                $post = get_post( $post );
     198                $this->assertEmpty( wp_cache_get( $id, 'posts' ) );
     199
     200                // get_post( WP_Post ) should not prime the cache
     201                get_post( $post );
     202                $this->assertEmpty( wp_cache_get( $id, 'posts' ) );
     203
     204                // get_post( ID ) should prime the cache
     205                get_post( $post->ID );
     206                $this->assertNotEmpty( wp_cache_get( $id, 'posts' ) );
     207        }
    188208}