[ Index ] |
PHP Cross Reference of BBPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Tests for the cache functions. 4 * 5 * @group cache 6 */ 7 class BBP_Core_Cache_Tests extends BBP_UnitTestCase { 8 9 /** 10 * @group counts 11 * @covers ::bbp_clean_post_cache 12 */ 13 public function test_bbp_clean_post_cache() { 14 15 // Get the post types. 16 $tpt = bbp_get_topic_post_type(); 17 $rpt = bbp_get_reply_post_type(); 18 19 // Set up a forum with 1 topic and 1 reply to that topic. 20 $f = $this->factory->forum->create(); 21 $t = $this->factory->topic->create( array( 22 'post_parent' => $f, 23 'topic_meta' => array( 24 'forum_id' => $f, 25 ), 26 ) ); 27 $r = $this->factory->reply->create( array( 28 'post_parent' => $t, 29 'reply_meta' => array( 30 'forum_id' => $f, 31 'topic_id' => $t, 32 ), 33 ) ); 34 35 // Make sure we've cached some data. 36 bbp_get_all_child_ids( $f, $tpt ); 37 bbp_get_all_child_ids( $t, $rpt ); 38 39 // Setup 40 $f_key = md5( serialize( array( 'parent_id' => $f, 'post_type' => $tpt ) ) ); 41 $t_key = md5( serialize( array( 'parent_id' => $t, 'post_type' => $rpt ) ) ); 42 $last_changed = wp_cache_get_last_changed( 'bbpress_posts' ); 43 44 // Keys 45 $f_key = "bbp_child_ids:{$f_key}:{$last_changed}"; 46 $t_key = "bbp_child_ids:{$t_key}:{$last_changed}"; 47 48 $this->assertEquals( array( $t ), wp_cache_get( $f_key, 'bbpress_posts' ) ); 49 $this->assertEquals( array( $r ), wp_cache_get( $t_key, 'bbpress_posts' ) ); 50 51 // Clean the reply cache. 52 clean_post_cache( $r ); 53 54 // Setup 55 $last_changed = wp_cache_get_last_changed( 'bbpress_posts' ); 56 57 // Keys 58 $f_key = "bbp_child_ids:{$f_key}:{$last_changed}"; 59 $t_key = "bbp_child_ids:{$t_key}:{$last_changed}"; 60 61 $this->assertEquals( false, wp_cache_get( $f_key, 'bbpress_posts' ) ); 62 $this->assertEquals( false, wp_cache_get( $t_key, 'bbpress_posts' ) ); 63 } 64 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Dec 21 01:00:52 2024 | Cross-referenced by PHPXref 0.7.1 |