Changeset 42343 for trunk/tests/phpunit/tests/term/wpGenerateTagCloud.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/wpGenerateTagCloud.php
r40816 r42343 28 28 */ 29 29 function test_empty_tags_list_returned( $expected, $args ) { 30 $term_ids = self::factory()->term->create_many( 4, array( 'taxonomy' => 'post_tag' ) );30 $term_ids = self::factory()->term->create_many( 4, array( 'taxonomy' => 'post_tag' ) ); 31 31 $this->terms = array(); 32 32 foreach ( $term_ids as $term_id ) { … … 39 39 /** 40 40 * Provider for test when tags are empty. 41 * 41 42 * @return array 42 43 */ 43 function empty_tags_data_provider () {44 function empty_tags_data_provider() { 44 45 return array( 45 46 /** … … 73 74 function test_hide_empty_false() { 74 75 $term_id = self::factory()->tag->create(); 75 $term = get_term( $term_id, 'post_tag' ); 76 77 $tags = $this->retrieve_terms( array( 78 'number' => 1, 79 'hide_empty' => false, 80 ) ); 81 82 $found = wp_generate_tag_cloud( $tags, array( 83 'hide_empty' => false, 84 ) ); 76 $term = get_term( $term_id, 'post_tag' ); 77 78 $tags = $this->retrieve_terms( 79 array( 80 'number' => 1, 81 'hide_empty' => false, 82 ) 83 ); 84 85 $found = wp_generate_tag_cloud( 86 $tags, array( 87 'hide_empty' => false, 88 ) 89 ); 85 90 86 91 $this->assertContains( '>' . $tags[0]->name . '<', $found ); … … 89 94 function test_hide_empty_false_format_array() { 90 95 $term_id = self::factory()->tag->create(); 91 $term = get_term( $term_id, 'post_tag' ); 92 93 $tags = $this->retrieve_terms( array( 94 'number' => 1, 95 'hide_empty' => false, 96 'format' => 'array', 97 ) ); 98 99 $found = wp_generate_tag_cloud( $tags, array( 100 'hide_empty' => false, 101 'format' => 'array', 102 ) ); 96 $term = get_term( $term_id, 'post_tag' ); 97 98 $tags = $this->retrieve_terms( 99 array( 100 'number' => 1, 101 'hide_empty' => false, 102 'format' => 'array', 103 ) 104 ); 105 106 $found = wp_generate_tag_cloud( 107 $tags, array( 108 'hide_empty' => false, 109 'format' => 'array', 110 ) 111 ); 103 112 104 113 $this->assertInternalType( 'array', $found ); … … 108 117 function test_hide_empty_false_format_list() { 109 118 $term_id = self::factory()->tag->create(); 110 $term = get_term( $term_id, 'post_tag' ); 111 112 $tags = $this->retrieve_terms( array( 113 'number' => 1, 114 'hide_empty' => false, 115 ) ); 116 117 $found = wp_generate_tag_cloud( $tags, array( 118 'hide_empty' => false, 119 'format' => 'list', 120 ) ); 119 $term = get_term( $term_id, 'post_tag' ); 120 121 $tags = $this->retrieve_terms( 122 array( 123 'number' => 1, 124 'hide_empty' => false, 125 ) 126 ); 127 128 $found = wp_generate_tag_cloud( 129 $tags, array( 130 'hide_empty' => false, 131 'format' => 'list', 132 ) 133 ); 121 134 122 135 $this->assertRegExp( "|^<ul class='wp-tag-cloud' role='list'>|", $found ); … … 127 140 function test_hide_empty_false_multi() { 128 141 $term_ids = self::factory()->tag->create_many( 4 ); 129 $terms = array();142 $terms = array(); 130 143 foreach ( $term_ids as $term_id ) { 131 144 $terms[] = get_term( $term_id, 'post_tag' ); 132 145 } 133 146 134 $tags = $this->retrieve_terms( array( 135 'number' => 4, 136 'order' => 'id', 137 'hide_empty' => false, 138 ) ); 139 140 $found = wp_generate_tag_cloud( $tags, array( 141 'hide_empty' => false, 142 ) ); 147 $tags = $this->retrieve_terms( 148 array( 149 'number' => 4, 150 'order' => 'id', 151 'hide_empty' => false, 152 ) 153 ); 154 155 $found = wp_generate_tag_cloud( 156 $tags, array( 157 'hide_empty' => false, 158 ) 159 ); 143 160 144 161 foreach ( $tags as $tag ) { … … 149 166 function test_hide_empty_false_multi_format_list() { 150 167 $term_ids = self::factory()->tag->create_many( 4 ); 151 $terms = array();168 $terms = array(); 152 169 foreach ( $term_ids as $term_id ) { 153 170 $terms[] = get_term( $term_id, 'post_tag' ); 154 171 } 155 172 156 $tags = $this->retrieve_terms( array( 157 'number' => 4, 158 'orderby' => 'id', 159 'hide_empty' => false, 160 ) ); 161 162 $found = wp_generate_tag_cloud( $tags, array( 163 'hide_empty' => false, 164 'format' => 'list', 165 ) ); 173 $tags = $this->retrieve_terms( 174 array( 175 'number' => 4, 176 'orderby' => 'id', 177 'hide_empty' => false, 178 ) 179 ); 180 181 $found = wp_generate_tag_cloud( 182 $tags, array( 183 'hide_empty' => false, 184 'format' => 'list', 185 ) 186 ); 166 187 167 188 $this->assertRegExp( "|^<ul class='wp-tag-cloud' role='list'>|", $found ); … … 175 196 public function test_topic_count_text() { 176 197 register_taxonomy( 'wptests_tax', 'post' ); 177 $term_ids = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );198 $term_ids = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 178 199 $this->terms = array(); 179 200 foreach ( $term_ids as $term_id ) { … … 185 206 wp_set_post_terms( $posts[1], array( $term_ids[1] ), 'wptests_tax' ); 186 207 187 $term_objects = $this->retrieve_terms( array( 188 'include' => $term_ids, 189 ), 'wptests_tax' ); 190 191 $actual = wp_generate_tag_cloud( $term_objects, array( 192 'format' => 'array', 193 'topic_count_text' => array( 194 'singular' => 'Term has %s post', 195 'plural' => 'Term has %s posts', 196 'domain' => 'foo', 197 'context' => 'bar', 198 ), 199 ) ); 208 $term_objects = $this->retrieve_terms( 209 array( 210 'include' => $term_ids, 211 ), 'wptests_tax' 212 ); 213 214 $actual = wp_generate_tag_cloud( 215 $term_objects, array( 216 'format' => 'array', 217 'topic_count_text' => array( 218 'singular' => 'Term has %s post', 219 'plural' => 'Term has %s posts', 220 'domain' => 'foo', 221 'context' => 'bar', 222 ), 223 ) 224 ); 200 225 201 226 $this->assertContains( 'aria-label="' . $term_objects[0]->name . ' (Term has 1 post)"', $actual[0] ); … … 205 230 public function test_topic_count_text_callback() { 206 231 register_taxonomy( 'wptests_tax', 'post' ); 207 $term_ids = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );232 $term_ids = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 208 233 $this->terms = array(); 209 234 foreach ( $term_ids as $term_id ) { … … 215 240 wp_set_post_terms( $posts[1], array( $term_ids[1] ), 'wptests_tax' ); 216 241 217 $term_objects = $this->retrieve_terms( array( 218 'include' => $term_ids, 219 ), 'wptests_tax' ); 220 221 $actual = wp_generate_tag_cloud( $term_objects, array( 222 'format' => 'array', 223 'topic_count_text_callback' => array( $this, 'topic_count_text_callback' ), 224 ) ); 242 $term_objects = $this->retrieve_terms( 243 array( 244 'include' => $term_ids, 245 ), 'wptests_tax' 246 ); 247 248 $actual = wp_generate_tag_cloud( 249 $term_objects, array( 250 'format' => 'array', 251 'topic_count_text_callback' => array( $this, 'topic_count_text_callback' ), 252 ) 253 ); 225 254 226 255 $this->assertContains( 'aria-label="' . $term_objects[0]->name . ' (1 foo)"', $actual[0] ); … … 238 267 wp_set_post_terms( $p, $term_ids, 'wptests_tax' ); 239 268 240 $term_objects = get_terms( 'wptests_tax', array( 241 'include' => $term_ids, 242 ) ); 269 $term_objects = get_terms( 270 'wptests_tax', array( 271 'include' => $term_ids, 272 ) 273 ); 243 274 244 275 $cloud = wp_generate_tag_cloud( $term_objects ); … … 264 295 //add the link 265 296 $term->link = get_term_link( $term ); 266 $tags[] = $term;297 $tags[] = $term; 267 298 268 299 }
Note: See TracChangeset
for help on using the changeset viewer.