| 1 | Index: tests/post/objects.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- tests/post/objects.php (revision 1085) |
|---|
| 4 | +++ tests/post/objects.php (working copy) |
|---|
| 5 | @@ -185,4 +185,24 @@ |
|---|
| 6 | $this->assertInternalType( 'array', $post['ancestors'] ); |
|---|
| 7 | $this->assertEquals( 'raw', $post['filter'] ); |
|---|
| 8 | } |
|---|
| 9 | + |
|---|
| 10 | + function test_get_post_cache() { |
|---|
| 11 | + global $wpdb; |
|---|
| 12 | + |
|---|
| 13 | + $id = $this->factory->post->create(); |
|---|
| 14 | + wp_cache_delete( $id, 'posts' ); |
|---|
| 15 | + |
|---|
| 16 | + // get_post( stdClass ) should not prime the cache |
|---|
| 17 | + $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id ) ); |
|---|
| 18 | + $post = get_post( $post ); |
|---|
| 19 | + $this->assertEmpty( wp_cache_get( $id, 'posts' ) ); |
|---|
| 20 | + |
|---|
| 21 | + // get_post( WP_Post ) should not prime the cache |
|---|
| 22 | + get_post( $post ); |
|---|
| 23 | + $this->assertEmpty( wp_cache_get( $id, 'posts' ) ); |
|---|
| 24 | + |
|---|
| 25 | + // get_post( ID ) should prime the cache |
|---|
| 26 | + get_post( $post->ID ); |
|---|
| 27 | + $this->assertNotEmpty( wp_cache_get( $id, 'posts' ) ); |
|---|
| 28 | + } |
|---|
| 29 | } |
|---|