| | 1 | <?php |
| | 2 | |
| | 3 | /** |
| | 4 | * @group taxonomy |
| | 5 | */ |
| | 6 | class Tests_Term_GetEditTermLink extends WP_UnitTestCase { |
| | 7 | |
| | 8 | public function setUp() { |
| | 9 | parent::setUp(); |
| | 10 | wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); |
| | 11 | register_taxonomy( 'wptests_tax', 'post' ); |
| | 12 | |
| | 13 | } |
| | 14 | |
| | 15 | public function test_get_edit_term_link_default() { |
| | 16 | |
| | 17 | $term1 = $this->factory->term->create( array( |
| | 18 | 'taxonomy' => 'wptests_tax', |
| | 19 | 'name' => 'foo', |
| | 20 | ) ); |
| | 21 | |
| | 22 | $actual = get_edit_term_link( $term1, 'wptests_tax' ); |
| | 23 | $expected = 'http://example.org/wp-admin/edit-tags.php?action=edit&taxonomy=wptests_tax&tag_ID=' . $term1 . '&post_type=post'; |
| | 24 | $this->assertEquals( $actual, $expected ); |
| | 25 | } |
| | 26 | |
| | 27 | public function test_get_edit_term_link_invalid_id() { |
| | 28 | |
| | 29 | $term1 = $this->factory->term->create( array( |
| | 30 | 'taxonomy' => 'wptests_tax', |
| | 31 | 'name' => 'foo', |
| | 32 | ) ); |
| | 33 | |
| | 34 | $actual = get_edit_term_link( 12345, 'wptests_tax' ); |
| | 35 | $this->assertNull( $actual ); |
| | 36 | } |
| | 37 | |
| | 38 | public function test_get_edit_term_link_empty_id() { |
| | 39 | $actual = get_edit_term_link( '', 'wptests_tax' ); |
| | 40 | $this->assertNull( $actual ); |
| | 41 | } |
| | 42 | |
| | 43 | public function test_get_edit_term_link_bad_tax() { |
| | 44 | $actual = get_edit_term_link( '', 'bad_tax' ); |
| | 45 | $this->assertNull( $actual ); |
| | 46 | } |
| | 47 | |
| | 48 | |
| | 49 | } |