/** * @group wp_query_hacks */ function testGettingWithCategory() { $cat = $this->factory->term->create(array('name' => 'News', 'taxonomy' => 'category')); $pids = $this->factory->post->create_many(6); $cats = $this->factory->post->create_many(3, array('post_category' => array($cat))); $cat_post = $this->factory->post->create(array('post_category' => array($cat))); $cat_post = new TimberPost($cat_post); $this->assertEquals('News', $cat_post->category()->name()); $posts = Timber::get_posts(array('category' => $cat)); $this->assertEquals(4, count($posts)); }
function testPostCategory() { $cat = wp_insert_term('News', 'category'); $pid = $this->factory->post->create(); wp_set_object_terms($pid, $cat['term_id'], 'category'); $post = new TimberPost($pid); $this->assertEquals('News', $post->category()->name); }