function testTermMetaFilter() { $tid = $this->factory->term->create(); $term = new TimberTerm($tid); add_filter('timber_term_get_meta_field', array($this, 'filter_timber_term_get_meta_field'), 10, 4); $term->meta("panic!"); }
function testTimberPostOnCategoryPage() { $post_id = $this->factory->post->create(); $category_id = $this->factory->term->create(array('taxonomy' => 'category', 'name' => 'News')); $cat = new TimberTerm($category_id); $this->go_to($cat->path()); $term = new TimberTerm(); $this->assertEquals($category_id, $term->ID); $post = new TimberPost(); $this->assertEquals(0, $post->ID); }
function testGetPostsNew() { require_once 'php/timber-post-subclass.php'; $term_id = $this->factory->term->create(); $posts = array(); $posts[] = $this->factory->post->create(); $posts[] = $this->factory->post->create(); $posts[] = $this->factory->post->create(); foreach ($posts as $post_id) { set_post_type($post_id, 'page'); wp_set_object_terms($post_id, $term_id, 'post_tag', true); } $term = new TimberTerm($term_id); $gotten_posts = $term->get_posts('post_type=page'); $this->assertEquals(count($posts), count($gotten_posts)); $gotten_posts = $term->get_posts('post_type=page', 'TimberPostSubclass'); $this->assertEquals(count($posts), count($gotten_posts)); $this->assertEquals($gotten_posts[0]->foo(), 'bar'); $gotten_posts = $term->get_posts(array('post_type' => 'page'), 'TimberPostSubclass'); $this->assertEquals($gotten_posts[0]->foo(), 'bar'); $this->assertEquals(count($posts), count($gotten_posts)); }
function testTermEditLink() { wp_set_current_user(1); $tid = $this->factory->term->create(array('name' => 'News', 'taxonomy' => 'category')); $term = new TimberTerm($tid); $links = array(); $links[] = 'http://example.org/wp-admin/term.php?taxonomy=category&tag_ID=' . $tid . '&post_type=post'; $links[] = 'http://example.org/wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=' . $tid . '&post_type=post'; $links[] = 'http://example.org/wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=' . $tid; $links[] = 'http://example.org/wp-admin/term.php?taxonomy=category&term_id=' . $tid . '&post_type=post'; $this->assertContains($term->edit_link(), $links); }
function testTermChildren() { $parent_id = $this->factory->term->create(array('name' => 'News', 'taxonomy' => 'category')); $local = $this->factory->term->create(array('name' => 'Local', 'parent' => $parent_id, 'taxonomy' => 'category')); $int = $this->factory->term->create(array('name' => 'International', 'parent' => $parent_id, 'taxonomy' => 'category')); $term = new TimberTerm($parent_id); $children = $term->children(); $this->assertEquals(2, count($children)); $this->assertEquals('Local', $children[0]->name); }
function get_page($i) { return $this->term->get_page($i); }