Changeset 454 in tests for wp-testcase/test_includes_taxonomy.php
- Timestamp:
- 10/14/2011 09:21:36 AM (15 years ago)
- File:
-
- 1 edited
-
wp-testcase/test_includes_taxonomy.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_includes_taxonomy.php
r432 r454 40 40 } 41 41 42 function test_ is_taxonomy_known() {43 $this->assertTrue( is_taxonomy('category') );44 $this->assertTrue( is_taxonomy('post_tag') );45 $this->assertTrue( is_taxonomy('link_category') );46 } 47 48 function test_ is_taxonomy_unknown() {49 $this->assertFalse( is_taxonomy(rand_str()) );50 $this->assertFalse( is_taxonomy('') );51 $this->assertFalse( is_taxonomy(0) );52 $this->assertFalse( is_taxonomy(NULL) );42 function test_taxonomy_exists_known() { 43 $this->assertTrue( taxonomy_exists('category') ); 44 $this->assertTrue( taxonomy_exists('post_tag') ); 45 $this->assertTrue( taxonomy_exists('link_category') ); 46 } 47 48 function test_taxonomy_exists_unknown() { 49 $this->assertFalse( taxonomy_exists(rand_str()) ); 50 $this->assertFalse( taxonomy_exists('') ); 51 $this->assertFalse( taxonomy_exists(0) ); 52 $this->assertFalse( taxonomy_exists(NULL) ); 53 53 } 54 54 … … 70 70 // make up a new taxonomy name, and ensure it's unused 71 71 $tax = rand_str(); 72 $this->assertFalse( is_taxonomy($tax) );72 $this->assertFalse( taxonomy_exists($tax) ); 73 73 74 74 register_taxonomy( $tax, 'post' ); 75 $this->assertTrue( is_taxonomy($tax) );75 $this->assertTrue( taxonomy_exists($tax) ); 76 76 $this->assertFalse( is_taxonomy_hierarchical($tax) ); 77 77 … … 84 84 // make up a new taxonomy name, and ensure it's unused 85 85 $tax = rand_str(); 86 $this->assertFalse( is_taxonomy($tax) );86 $this->assertFalse( taxonomy_exists($tax) ); 87 87 88 88 register_taxonomy( $tax, 'post', array('hierarchical'=>true) ); 89 $this->assertTrue( is_taxonomy($tax) );89 $this->assertTrue( taxonomy_exists($tax) ); 90 90 $this->assertTrue( is_taxonomy_hierarchical($tax) ); 91 91 … … 110 110 // a new unused term 111 111 $term = rand_str(); 112 $this->assertNull( is_term($term) );112 $this->assertNull( term_exists($term) ); 113 113 114 114 $initial_count = wp_count_terms( $this->taxonomy ); … … 122 122 123 123 // make sure the term exists 124 $this->assertTrue( is_term($term) > 0 );125 $this->assertTrue( is_term($t['term_id']) > 0 );124 $this->assertTrue( term_exists($term) > 0 ); 125 $this->assertTrue( term_exists($t['term_id']) > 0 ); 126 126 127 127 // now delete it 128 128 $this->assertTrue( wp_delete_term($t['term_id'], $this->taxonomy) ); 129 $this->assertNull( is_term($term) );130 $this->assertNull( is_term($t['term_id']) );129 $this->assertNull( term_exists($term) ); 130 $this->assertNull( term_exists($t['term_id']) ); 131 131 $this->assertEquals( $initial_count, wp_count_terms($this->taxonomy) ); 132 132 } 133 133 134 function test_ is_term_known() {134 function test_term_exists_known() { 135 135 // insert a term 136 136 $term = rand_str(); 137 137 $t = wp_insert_term( $term, $this->taxonomy ); 138 138 139 $this->assertEquals( $t['term_id'], is_term($t['term_id']) );140 $this->assertEquals( $t['term_id'], is_term($term) );139 $this->assertEquals( $t['term_id'], term_exists($t['term_id']) ); 140 $this->assertEquals( $t['term_id'], term_exists($term) ); 141 141 142 142 // clean up … … 144 144 } 145 145 146 function test_ is_term_unknown() {147 $this->assertNull( is_term(rand_str()) );148 $this->assertEquals( 0, is_term(0) );149 $this->assertEquals( 0, is_term('') );150 $this->assertEquals( 0, is_term(NULL) );146 function test_term_exists_unknown() { 147 $this->assertNull( term_exists(rand_str()) ); 148 $this->assertEquals( 0, term_exists(0) ); 149 $this->assertEquals( 0, term_exists('') ); 150 $this->assertEquals( 0, term_exists(NULL) ); 151 151 } 152 152 … … 158 158 159 159 $term_obj = get_term_by('name', $term, $this->taxonomy); 160 $this->assertEquals( $t['term_id'], is_term($term_obj->term_id) );160 $this->assertEquals( $t['term_id'], term_exists($term_obj->term_id) ); 161 161 162 162 // clean up
Note: See TracChangeset
for help on using the changeset viewer.