public function test_home_page_keys() { $wp_query = $this->getMockBuilder('WP_Query')->setMethods(array('get_queried_object', 'get', 'is_single', 'is_preview', 'is_page', 'is_archive', 'is_date', 'is_year', 'is_month', 'is_day', 'is_time', 'is_author', 'is_category', 'is_tag', 'is_tax', 'is_search', 'is_feed', 'is_comment_feed', 'is_trackback', 'is_home', 'is_404', 'is_comments_popup', 'is_paged', 'is_admin', 'is_attachment', 'is_singular', 'is_robots', 'is_posts_page', 'is_post_type_archive'))->getMock(); $template_type = 'home'; $wp_query->expects($this->any())->method('is_home')->will($this->returnValue(true)); $wp_query->post = $this->getMockBuilder('WP_Post')->getMock(); $wp_query->post->ID = 10; $wp_query->post->post_author = 23; $post2 = $this->getMockBuilder('WP_Post')->getMock(); $post2->ID = 11; $post2->post_author = 54; $wp_query->posts = array(clone $wp_query->post, clone $post2); $object = new Purgely_Surrogate_Key_Collection($wp_query); $expected_keys = array(0 => 'post-' . $wp_query->post->ID, 1 => 'post-' . $post2->ID, 2 => 'template-' . $template_type); $this->assertEquals($expected_keys, $object->get_keys()); }
/** * Set all the surrogate keys for the requests. * * @return void */ public function set_standard_keys() { global $wp_query; $key_collection = new Purgely_Surrogate_Key_Collection($wp_query); $keys = $key_collection->get_keys(); $this::$surrogate_keys_header->add_keys($keys); }