Changeset 54061 for trunk/tests/phpunit/tests/term/getTermLink.php
- Timestamp:
- 09/02/2022 01:14:29 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/getTermLink.php
r53836 r54061 38 38 * 39 39 * @param string $taxonomy Taxonomy being tested (used for index of term keys). 40 * @param bool $use_id Whe n true, pass term ID. Else, passterm object.41 * @return WP_Term|int If $use_id is true, term ID is returned; else instance of WP_Term.40 * @param bool $use_id Whether to return term ID or term object. 41 * @return WP_Term|int Term ID if `$use_id` is true, WP_Term instance otherwise. 42 42 */ 43 43 private function get_term( $taxonomy, $use_id ) { … … 248 248 249 249 /** 250 * @dataProvider data_ get_term_link250 * @dataProvider data_term_link_filter_should_receive_term_object 251 251 * 252 252 * @ticket 50225 253 253 * 254 * @param string $taxonomy Taxonomy being tested (used for index of term keys).255 * @param bool $use_id Whe n true, pass term ID. Else, pass term object.256 */ 257 public function test_ get_term_link_filter_is_object_by_term_id( $taxonomy, $use_id ) {254 * @param string $taxonomy Taxonomy being tested. 255 * @param bool $use_id Whether to pass term ID or term object to `get_term_link()`. 256 */ 257 public function test_term_link_filter_should_receive_term_object( $taxonomy, $use_id ) { 258 258 $term = $this->get_term( $taxonomy, $use_id ); 259 259 … … 271 271 272 272 /** 273 * @dataProvider data_get_term_link274 *275 * @ticket 50225276 *277 * @param string $taxonomy Taxonomy being tested (used for index of term keys).278 * @param bool $use_id When true, pass term ID. Else, pass term object.279 */280 public function test_get_term_link_filter_is_object_by_term_object( $taxonomy, $use_id ) {281 $term = $this->get_term( $taxonomy, $use_id );282 283 add_filter(284 'term_link',285 function( $location, $term ) {286 $this->assertInstanceOf( 'WP_Term', $term );287 },288 10,289 2290 );291 292 get_term_link( get_term( $term, $taxonomy ), $taxonomy );293 }294 295 /**296 * @dataProvider data_get_term_link297 *298 * @ticket 50225299 *300 * @param string $taxonomy Taxonomy being tested (used for index of term keys).301 * @param bool $use_id When true, pass term ID. Else, skip the test.302 */303 public function test_get_term_feed_link_backward_compatibility( $taxonomy, $use_id ) {304 if ( $use_id ) {305 $term = $this->get_term( $taxonomy, $use_id );306 307 $term_feed_link = get_term_feed_link( $term, $taxonomy );308 $this->assertIsString( $term_feed_link );309 310 $term_feed_link = get_term_feed_link( $term, '' );311 $this->assertIsString( $term_feed_link );312 } else {313 $this->markTestSkipped( 'This test requires to pass an ID to get_term_feed_link()' );314 }315 }316 317 /**318 273 * Data provider. 319 274 * 320 275 * @return array 321 276 */ 322 public function data_ get_term_link() {277 public function data_term_link_filter_should_receive_term_object() { 323 278 return array( 324 279 'category passing term_id' => array( … … 348 303 ); 349 304 } 305 306 /** 307 * @dataProvider data_get_term_feed_link_should_use_term_taxonomy_when_term_id_is_passed 308 * 309 * @ticket 50225 310 * 311 * @param string $taxonomy Taxonomy being tested. 312 */ 313 public function test_get_term_feed_link_should_use_term_taxonomy_when_term_id_is_passed( $taxonomy ) { 314 $term = $this->get_term( $taxonomy, true ); 315 316 $term_feed_link = get_term_feed_link( $term, $taxonomy ); 317 $this->assertIsString( $term_feed_link ); 318 319 $term_feed_link = get_term_feed_link( $term, '' ); 320 $this->assertIsString( $term_feed_link ); 321 } 322 323 /** 324 * Data provider. 325 * 326 * @return array 327 */ 328 public function data_get_term_feed_link_should_use_term_taxonomy_when_term_id_is_passed() { 329 $taxonomies = array( 'category', 'post_tag', 'wptests_tax' ); 330 331 return $this->text_array_to_dataprovider( $taxonomies ); 332 } 350 333 }
Note: See TracChangeset
for help on using the changeset viewer.