Changeset 47122 for trunk/tests/phpunit/tests/category.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/category.php
r46586 r47122 21 21 */ 22 22 function test_get_all_category_ids() { 23 // create categories23 // Ccreate categories. 24 24 self::factory()->category->create_many( 2 ); 25 25 26 // create new taxonomy to ensure not included26 // Create new taxonomy to ensure not included. 27 27 register_taxonomy( 'test_tax_cat', 'post' ); 28 28 wp_insert_term( 'test1', 'test_tax_cat' ); 29 29 30 // Validate length is 1 + created due to uncategorized 30 // Validate length is 1 + created due to uncategorized. 31 31 $cat_ids = get_all_category_ids(); 32 32 $this->assertEquals( 3, count( $cat_ids ) ); … … 38 38 function test_get_category_by_slug() { 39 39 40 // create Test Categories40 // Create test categories. 41 41 $testcat = self::factory()->category->create_and_get( 42 42 array( … … 52 52 ); 53 53 54 // validate category is returned by slug54 // Validate category is returned by slug. 55 55 $ret_testcat = get_category_by_slug( 'testcat' ); 56 56 $this->assertEquals( $testcat->term_id, $ret_testcat->term_id ); … … 58 58 $this->assertEquals( $testcat->term_id, $ret_testcat->term_id ); 59 59 60 // validate unknown category returns false60 // Validate unknown category returns false. 61 61 $this->assertFalse( get_category_by_slug( 'testcat3' ) ); 62 62 … … 68 68 function test__make_cat_compat() { 69 69 70 // create Test Categories and Array Representations70 // Create test categories and array representations. 71 71 $testcat_array = array( 72 72 'slug' => 'testmcc', … … 86 86 $testcat2_array['term_id'] = $testcat2->term_id; 87 87 88 // unset properties to enable validation of object88 // Unset properties to enable validation of object. 89 89 unset( $testcat->cat_ID ); 90 90 unset( $testcat->category_count ); … … 101 101 unset( $testcat2->category_parent ); 102 102 103 // make Compatible103 // Make compatible. 104 104 _make_cat_compat( $testcat ); 105 105 _make_cat_compat( $testcat2 ); … … 107 107 _make_cat_compat( $testcat2_array ); 108 108 109 // Validate Compatibility Object109 // Validate compatibility object. 110 110 $this->assertEquals( $testcat->cat_ID, $testcat->term_id ); 111 111 $this->assertEquals( $testcat->category_count, $testcat->count ); … … 115 115 $this->assertEquals( $testcat->category_parent, $testcat->parent ); 116 116 117 // Validate Compatibility Object with Parent117 // Validate compatibility object with parent. 118 118 $this->assertEquals( $testcat->cat_ID, $testcat->term_id ); 119 119 $this->assertEquals( $testcat->category_count, $testcat->count ); … … 123 123 $this->assertEquals( $testcat->category_parent, $testcat->parent ); 124 124 125 // Validate Compatibility Array125 // Validate compatibility array. 126 126 $this->assertEquals( $testcat_array['cat_ID'], $testcat_array['term_id'] ); 127 127 $this->assertEquals( $testcat_array['category_count'], $testcat_array['count'] ); … … 131 131 $this->assertEquals( $testcat_array['category_parent'], $testcat_array['parent'] ); 132 132 133 // Validate Compatibility Array with Parent133 // Validate compatibility array with parent. 134 134 $this->assertEquals( $testcat_array['cat_ID'], $testcat_array['term_id'] ); 135 135 $this->assertEquals( $testcat_array['category_count'], $testcat_array['count'] ); … … 145 145 function test_get_cat_name() { 146 146 147 // create Test Category147 // Create test category. 148 148 $testcat = self::factory()->category->create_and_get( 149 149 array( … … 153 153 ); 154 154 155 // Validate 155 // Validate. 156 156 $this->assertEquals( $testcat->name, get_cat_name( $testcat->term_id ) ); 157 157 $this->assertEquals( '', get_cat_name( -1 ) ); … … 165 165 function test_get_cat_ID() { 166 166 167 // create Test Category167 // Create test category. 168 168 $testcat = self::factory()->category->create_and_get( 169 169 array( … … 173 173 ); 174 174 175 // Validate 175 // Validate. 176 176 $this->assertEquals( $testcat->term_id, get_cat_ID( $testcat->name ) ); 177 177 $this->assertEquals( 0, get_cat_ID( 'NO CAT' ) ); … … 185 185 function test_get_category_by_path() { 186 186 187 // create Test Categories187 // Create test categories. 188 188 $root_id = self::factory()->category->create( 189 189 array( … … 199 199 $root_cat_cat_id = self::factory()->category->create( 200 200 array( 201 'slug' => 'cat', // note this is modified on create201 'slug' => 'cat', // Note this is modified on create. 202 202 'parent' => $root_cat_id, 203 203 ) … … 211 211 $root_path_cat_id = self::factory()->category->create( 212 212 array( 213 'slug' => 'cat', // note this is modified on create213 'slug' => 'cat', // Note this is modified on create. 214 214 'parent' => $root_path_id, 215 215 ) … … 223 223 $root_level_cat_id = self::factory()->category->create( 224 224 array( 225 'slug' => 'cat', // note this is modified on create225 'slug' => 'cat', // Note this is modified on create. 226 226 'parent' => $root_level_id, 227 227 ) 228 228 ); 229 229 230 // Validate Full Match230 // Validate full match. 231 231 $ret_cat = get_category_by_path( '/root/level-1', true ); 232 232 $this->assertEquals( $root_level_id, $ret_cat->term_id ); … … 234 234 $this->assertNull( get_category_by_path( 'nocat/nocat/', true ) ); 235 235 236 // Validate Partial Match236 // Validate partial match. 237 237 $ret_cat = get_category_by_path( 'level-1', false ); 238 238 $this->assertEquals( $root_level_id, $ret_cat->term_id );
Note: See TracChangeset
for help on using the changeset viewer.