Changeset 48840 for trunk/tests/phpunit/tests/term.php
- Timestamp:
- 08/21/2020 10:30:06 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term.php
r48043 r48840 66 66 */ 67 67 function test_wp_count_terms() { 68 $count = wp_count_terms( 'category', array( 'hide_empty' => true ) ); 68 $count = wp_count_terms( 69 array( 70 'hide_empty' => true, 71 'taxonomy' => 'category', 72 ) 73 ); 69 74 // There are 5 posts, all Uncategorized. 70 75 $this->assertEquals( 1, $count ); 76 } 77 78 /** 79 * @ticket 36399 80 */ 81 function test_wp_count_terms_legacy_interoperability() { 82 self::factory()->tag->create_many( 5 ); 83 84 // Counts all terms (1 default category, 5 tags). 85 $count = wp_count_terms(); 86 $this->assertEquals( 6, $count ); 87 88 // Counts only tags (5), with both current and legacy signature. 89 // Legacy usage should not trigger deprecated notice. 90 $count = wp_count_terms( array( 'taxonomy' => 'post_tag' ) ); 91 $legacy_count = wp_count_terms( 'post_tag' ); 92 $this->assertEquals( 5, $count ); 93 $this->assertEquals( $count, $legacy_count ); 71 94 } 72 95 … … 128 151 $this->assertNull( category_exists( $term ) ); 129 152 130 $initial_count = wp_count_terms( 'category');153 $initial_count = wp_count_terms( array( 'taxonomy' => 'category' ) ); 131 154 132 155 $t = wp_insert_category( array( 'cat_name' => $term ) ); … … 134 157 $this->assertNotWPError( $t ); 135 158 $this->assertTrue( $t > 0 ); 136 $this->assertEquals( $initial_count + 1, wp_count_terms( 'category') );159 $this->assertEquals( $initial_count + 1, wp_count_terms( array( 'taxonomy' => 'category' ) ) ); 137 160 138 161 // Make sure the term exists. … … 144 167 $this->assertNull( term_exists( $term ) ); 145 168 $this->assertNull( term_exists( $t ) ); 146 $this->assertEquals( $initial_count, wp_count_terms( 'category') );169 $this->assertEquals( $initial_count, wp_count_terms( array( 'taxonomy' => 'category' ) ) ); 147 170 } 148 171
Note: See TracChangeset
for help on using the changeset viewer.