| | 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 | } |