Changeset 42343 for trunk/tests/phpunit/tests/term/termExists.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/termExists.php
r35242 r42343 10 10 11 11 public function test_term_exists_term_int_taxonomy_nonempty_term_exists() { 12 $t = self::factory()->term->create( array( 13 'taxonomy' => 'post_tag', 14 ) ); 12 $t = self::factory()->term->create( 13 array( 14 'taxonomy' => 'post_tag', 15 ) 16 ); 15 17 16 18 $found = term_exists( intval( $t ), 'post_tag' ); … … 23 25 24 26 public function test_term_exists_term_int_taxonomy_nonempty_wrong_taxonomy() { 25 $t = self::factory()->term->create( array( 26 'taxonomy' => 'post_tag', 27 ) ); 27 $t = self::factory()->term->create( 28 array( 29 'taxonomy' => 'post_tag', 30 ) 31 ); 28 32 29 33 $this->assertNull( term_exists( intval( $t ), 'foo' ) ); … … 31 35 32 36 public function test_term_exists_term_int_taxonomy_empty_term_exists() { 33 $t = self::factory()->term->create( array( 34 'taxonomy' => 'post_tag', 35 ) ); 37 $t = self::factory()->term->create( 38 array( 39 'taxonomy' => 'post_tag', 40 ) 41 ); 36 42 37 43 $found = term_exists( intval( $t ), 'post_tag' ); … … 44 50 45 51 public function test_term_exists_unslash_term() { 46 $t = self::factory()->term->create( array( 47 'taxonomy' => 'post_tag', 48 'name' => 'I "love" WordPress\'s taxonomy system', 49 ) ); 52 $t = self::factory()->term->create( 53 array( 54 'taxonomy' => 'post_tag', 55 'name' => 'I "love" WordPress\'s taxonomy system', 56 ) 57 ); 50 58 51 59 $found = term_exists( 'I \"love\" WordPress\\\'s taxonomy system' ); … … 54 62 55 63 public function test_term_exists_trim_term() { 56 $t = self::factory()->term->create( array( 57 'taxonomy' => 'post_tag', 58 'slug' => 'foo', 59 ) ); 64 $t = self::factory()->term->create( 65 array( 66 'taxonomy' => 'post_tag', 67 'slug' => 'foo', 68 ) 69 ); 60 70 61 71 $found = term_exists( ' foo ' ); … … 81 91 82 92 public function test_term_exists_taxonomy_nonempty_parent_nonempty_match_slug() { 83 register_taxonomy( 'foo', 'post', array( 84 'hierarchical' => true, 85 ) ); 86 87 $parent_term = self::factory()->term->create( array( 88 'taxonomy' => 'foo', 89 ) ); 90 91 $t = self::factory()->term->create( array( 92 'taxonomy' => 'foo', 93 'parent' => $parent_term, 94 'slug' => 'child-term', 95 ) ); 93 register_taxonomy( 94 'foo', 'post', array( 95 'hierarchical' => true, 96 ) 97 ); 98 99 $parent_term = self::factory()->term->create( 100 array( 101 'taxonomy' => 'foo', 102 ) 103 ); 104 105 $t = self::factory()->term->create( 106 array( 107 'taxonomy' => 'foo', 108 'parent' => $parent_term, 109 'slug' => 'child-term', 110 ) 111 ); 96 112 97 113 $found = term_exists( 'child-term', 'foo', $parent_term ); … … 107 123 */ 108 124 public function test_term_exists_taxonomy_nonempty_parent_0_should_return_false_for_child_term() { 109 register_taxonomy( 'foo', 'post', array( 110 'hierarchical' => true, 111 ) ); 112 113 $parent_term = self::factory()->term->create( array( 114 'taxonomy' => 'foo', 115 ) ); 116 117 $t = self::factory()->term->create( array( 118 'taxonomy' => 'foo', 119 'parent' => $parent_term, 120 'slug' => 'child-term', 121 ) ); 125 register_taxonomy( 126 'foo', 'post', array( 127 'hierarchical' => true, 128 ) 129 ); 130 131 $parent_term = self::factory()->term->create( 132 array( 133 'taxonomy' => 'foo', 134 ) 135 ); 136 137 $t = self::factory()->term->create( 138 array( 139 'taxonomy' => 'foo', 140 'parent' => $parent_term, 141 'slug' => 'child-term', 142 ) 143 ); 122 144 123 145 $found = term_exists( 'child-term', 'foo', 0 ); … … 129 151 130 152 public function test_term_exists_taxonomy_nonempty_parent_nonempty_match_name() { 131 register_taxonomy( 'foo', 'post', array( 132 'hierarchical' => true, 133 ) ); 134 135 $parent_term = self::factory()->term->create( array( 136 'taxonomy' => 'foo', 137 ) ); 138 139 $t = self::factory()->term->create( array( 140 'taxonomy' => 'foo', 141 'parent' => $parent_term, 142 'name' => 'Child Term', 143 ) ); 153 register_taxonomy( 154 'foo', 'post', array( 155 'hierarchical' => true, 156 ) 157 ); 158 159 $parent_term = self::factory()->term->create( 160 array( 161 'taxonomy' => 'foo', 162 ) 163 ); 164 165 $t = self::factory()->term->create( 166 array( 167 'taxonomy' => 'foo', 168 'parent' => $parent_term, 169 'name' => 'Child Term', 170 ) 171 ); 144 172 145 173 $found = term_exists( 'Child Term', 'foo', $parent_term ); … … 154 182 register_taxonomy( 'foo', 'post', array() ); 155 183 156 $t = self::factory()->term->create( array( 157 'taxonomy' => 'foo', 158 'slug' => 'kewl-dudez', 159 ) ); 184 $t = self::factory()->term->create( 185 array( 186 'taxonomy' => 'foo', 187 'slug' => 'kewl-dudez', 188 ) 189 ); 160 190 161 191 $found = term_exists( 'kewl-dudez', 'foo' ); … … 170 200 register_taxonomy( 'foo', 'post', array() ); 171 201 172 $t = self::factory()->term->create( array( 173 'taxonomy' => 'foo', 174 'name' => 'Kewl Dudez', 175 ) ); 202 $t = self::factory()->term->create( 203 array( 204 'taxonomy' => 'foo', 205 'name' => 'Kewl Dudez', 206 ) 207 ); 176 208 177 209 $found = term_exists( 'Kewl Dudez', 'foo' ); … … 186 218 register_taxonomy( 'foo', 'post', array() ); 187 219 188 $t = self::factory()->term->create( array( 189 'taxonomy' => 'foo', 190 'name' => 'juicy-fruit', 191 ) ); 220 $t = self::factory()->term->create( 221 array( 222 'taxonomy' => 'foo', 223 'name' => 'juicy-fruit', 224 ) 225 ); 192 226 193 227 $found = term_exists( 'juicy-fruit' ); … … 202 236 register_taxonomy( 'foo', 'post', array() ); 203 237 204 $t = self::factory()->term->create( array( 205 'taxonomy' => 'foo', 206 'name' => 'Juicy Fruit', 207 ) ); 238 $t = self::factory()->term->create( 239 array( 240 'taxonomy' => 'foo', 241 'name' => 'Juicy Fruit', 242 ) 243 ); 208 244 209 245 $found = term_exists( 'Juicy Fruit' ); … … 220 256 // insert a term 221 257 $term = rand_str(); 222 $t = wp_insert_term( $term, 'wptests_tax' );258 $t = wp_insert_term( $term, 'wptests_tax' ); 223 259 $this->assertInternalType( 'array', $t ); 224 $this->assertEquals( $t['term_id'], term_exists( $t['term_id']) );225 $this->assertEquals( $t['term_id'], term_exists( $term) );260 $this->assertEquals( $t['term_id'], term_exists( $t['term_id'] ) ); 261 $this->assertEquals( $t['term_id'], term_exists( $term ) ); 226 262 227 263 // clean up … … 231 267 232 268 function test_term_exists_unknown() { 233 $this->assertNull( term_exists( rand_str()) );234 $this->assertEquals( 0, term_exists( 0) );235 $this->assertEquals( 0, term_exists( '') );236 $this->assertEquals( 0, term_exists( NULL) );269 $this->assertNull( term_exists( rand_str() ) ); 270 $this->assertEquals( 0, term_exists( 0 ) ); 271 $this->assertEquals( 0, term_exists( '' ) ); 272 $this->assertEquals( 0, term_exists( null ) ); 237 273 } 238 274 }
Note: See TracChangeset
for help on using the changeset viewer.