Changeset 42343 for trunk/tests/phpunit/tests/category.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/category.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/category.php
r37464 r42343 26 26 // create new taxonomy to ensure not included 27 27 register_taxonomy( 'test_tax_cat', 'post' ); 28 wp_insert_term( "test1", 'test_tax_cat' );28 wp_insert_term( 'test1', 'test_tax_cat' ); 29 29 30 30 // Validate length is 1 + created due to uncategorized 31 31 $cat_ids = get_all_category_ids(); 32 $this->assertEquals( 3, count( $cat_ids));32 $this->assertEquals( 3, count( $cat_ids ) ); 33 33 } 34 34 … … 39 39 40 40 // create Test Categories 41 $testcat = self::factory()->category->create_and_get(41 $testcat = self::factory()->category->create_and_get( 42 42 array( 43 43 'slug' => 'testcat', 44 'name' => 'Test Category 1' 44 'name' => 'Test Category 1', 45 45 ) 46 46 ); … … 48 48 array( 49 49 'slug' => 'testcat2', 50 'name' => 'Test Category 2' 50 'name' => 'Test Category 2', 51 51 ) 52 52 ); … … 69 69 70 70 // create Test Categories and Array Representations 71 $testcat_array = array(72 'slug' => 'testmcc',73 'name' => 'Test MCC',74 'description' => 'Category Test' 75 ); 76 $testcat = self::factory()->category->create_and_get( $testcat_array );71 $testcat_array = array( 72 'slug' => 'testmcc', 73 'name' => 'Test MCC', 74 'description' => 'Category Test', 75 ); 76 $testcat = self::factory()->category->create_and_get( $testcat_array ); 77 77 $testcat_array['term_id'] = $testcat->term_id; 78 78 79 $testcat2_array = array(80 'slug' => 'testmcc',81 'name' => 'Test MCC',79 $testcat2_array = array( 80 'slug' => 'testmcc', 81 'name' => 'Test MCC', 82 82 'description' => 'Category Test', 83 'parent' => $testcat->term_id84 ); 85 $testcat2 = self::factory()->category->create_and_get( $testcat2_array );83 'parent' => $testcat->term_id, 84 ); 85 $testcat2 = self::factory()->category->create_and_get( $testcat2_array ); 86 86 $testcat2_array['term_id'] = $testcat2->term_id; 87 87 … … 149 149 array( 150 150 'slug' => 'testcat', 151 'name' => 'Test Category 1' 151 'name' => 'Test Category 1', 152 152 ) 153 153 ); … … 169 169 array( 170 170 'slug' => 'testcat', 171 'name' => 'Test Category 1' 171 'name' => 'Test Category 1', 172 172 ) 173 173 ); … … 175 175 // Validate 176 176 $this->assertEquals( $testcat->term_id, get_cat_ID( $testcat->name ) ); 177 $this->assertEquals( 0, get_cat_ID( "NO CAT") );177 $this->assertEquals( 0, get_cat_ID( 'NO CAT' ) ); 178 178 $this->assertEquals( 0, get_cat_ID( 12 ) ); 179 179 … … 186 186 187 187 // create Test Categories 188 $root_id = self::factory()->category->create(188 $root_id = self::factory()->category->create( 189 189 array( 190 190 'slug' => 'root', 191 191 ) 192 192 ); 193 $root_cat_id = self::factory()->category->create(194 array( 195 'slug' => 'cat',196 'parent' => $root_id 197 ) 198 ); 199 $root_cat_cat_id = self::factory()->category->create(200 array( 201 'slug' => 'cat', //note this is modified on create202 'parent' => $root_cat_id 203 ) 204 ); 205 $root_path_id = self::factory()->category->create(206 array( 207 'slug' => 'path',208 'parent' => $root_id 209 ) 210 ); 211 $root_path_cat_id = self::factory()->category->create(212 array( 213 'slug' => 'cat', //note this is modified on create214 'parent' => $root_path_id 215 ) 216 ); 217 $root_level_id = self::factory()->category->create(218 array( 219 'slug' => 'level-1',220 'parent' => $root_id 193 $root_cat_id = self::factory()->category->create( 194 array( 195 'slug' => 'cat', 196 'parent' => $root_id, 197 ) 198 ); 199 $root_cat_cat_id = self::factory()->category->create( 200 array( 201 'slug' => 'cat', //note this is modified on create 202 'parent' => $root_cat_id, 203 ) 204 ); 205 $root_path_id = self::factory()->category->create( 206 array( 207 'slug' => 'path', 208 'parent' => $root_id, 209 ) 210 ); 211 $root_path_cat_id = self::factory()->category->create( 212 array( 213 'slug' => 'cat', //note this is modified on create 214 'parent' => $root_path_id, 215 ) 216 ); 217 $root_level_id = self::factory()->category->create( 218 array( 219 'slug' => 'level-1', 220 'parent' => $root_id, 221 221 ) 222 222 ); 223 223 $root_level_cat_id = self::factory()->category->create( 224 224 array( 225 'slug' => 'cat', //note this is modified on create226 'parent' => $root_level_id 225 'slug' => 'cat', //note this is modified on create 226 'parent' => $root_level_id, 227 227 ) 228 228 ); … … 232 232 $this->assertEquals( $root_level_id, $ret_cat->term_id ); 233 233 $this->assertNull( get_category_by_path( 'level-1', true ) ); 234 $this->assertNull( get_category_by_path( 'nocat/nocat/', true ) );234 $this->assertNull( get_category_by_path( 'nocat/nocat/', true ) ); 235 235 236 236 // Validate Partial Match … … 241 241 $ret_cat = get_category_by_path( 'root$2Fcat%20%2Flevel-1', false ); 242 242 $this->assertEquals( $root_level_id, $ret_cat->term_id ); 243 $this->assertNull( get_category_by_path( 'nocat/nocat/', false ) );243 $this->assertNull( get_category_by_path( 'nocat/nocat/', false ) ); 244 244 } 245 245 }
Note: See TracChangeset
for help on using the changeset viewer.