WordPress.org

Make WordPress Core

Changeset 1086 in tests


Ignore:
Timestamp:
10/19/12 21:53:51 (18 months ago)
Author:
ryan
Message:

Tests for cache priming in get_post(). see #WP22223

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/post/objects.php

    r995 r1086  
    186186        $this->assertEquals( 'raw', $post['filter'] ); 
    187187    } 
     188 
     189    /** 
     190     * @ticket 22223 
     191     */ 
     192    function test_get_post_cache() { 
     193        global $wpdb; 
     194 
     195        $id = $this->factory->post->create(); 
     196        wp_cache_delete( $id, 'posts' ); 
     197 
     198        // get_post( stdClass ) should not prime the cache 
     199        $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id ) ); 
     200        $post = get_post( $post ); 
     201        $this->assertEmpty( wp_cache_get( $id, 'posts' ) ); 
     202 
     203        // get_post( WP_Post ) should not prime the cache 
     204        get_post( $post ); 
     205        $this->assertEmpty( wp_cache_get( $id, 'posts' ) ); 
     206 
     207        // get_post( ID ) should prime the cache 
     208        get_post( $post->ID ); 
     209        $this->assertNotEmpty( wp_cache_get( $id, 'posts' ) ); 
     210    } 
    188211} 
Note: See TracChangeset for help on using the changeset viewer.