Changeset 31248 for trunk/tests/phpunit/tests/term/getTerms.php
- Timestamp:
- 01/19/2015 04:51:44 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/getTerms.php
r31207 r31248 1078 1078 } 1079 1079 1080 /* 1080 public function test_pad_counts() { 1081 register_taxonomy( 'wptests_tax_1', 'post', array( 'hierarchical' => true ) ); 1082 1083 $posts = $this->factory->post->create_many( 3 ); 1084 1085 $t1 = $this->factory->term->create( array( 1086 'taxonomy' => 'wptests_tax_1', 1087 ) ); 1088 $t2 = $this->factory->term->create( array( 1089 'taxonomy' => 'wptests_tax_1', 1090 'parent' => $t1, 1091 ) ); 1092 $t3 = $this->factory->term->create( array( 1093 'taxonomy' => 'wptests_tax_1', 1094 'parent' => $t2, 1095 ) ); 1096 1097 wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax_1' ); 1098 wp_set_object_terms( $posts[1], array( $t2 ), 'wptests_tax_1' ); 1099 wp_set_object_terms( $posts[2], array( $t3 ), 'wptests_tax_1' ); 1100 1101 $found = get_terms( 'wptests_tax_1', array( 1102 'pad_counts' => true, 1103 ) ); 1104 1105 $this->assertEqualSets( array( $t1, $t2, $t3 ), wp_list_pluck( $found, 'term_id' ) ); 1106 1107 foreach ( $found as $f ) { 1108 if ( $t1 == $f->term_id ) { 1109 $this->assertSame( 3, $f->count ); 1110 } elseif ( $t2 == $f->term_id ) { 1111 $this->assertSame( 2, $f->count ); 1112 } else { 1113 $this->assertSame( 1, $f->count ); 1114 } 1115 } 1116 } 1117 1118 /** 1081 1119 * @ticket 20635 1082 1120 */ … … 1101 1139 1102 1140 $this->assertEqualSets( array( $c1, $c2, $c3 ), wp_list_pluck( $terms, 'term_id' ) ); 1141 1142 foreach ( $terms as $term ) { 1143 $this->assertSame( 3, $term->count ); 1144 } 1103 1145 } 1104 1146
Note: See TracChangeset
for help on using the changeset viewer.