mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 10:44:26 +00:00
Introduced $field argument to get_term_link().
This new argument allows developers to specify which term field should be matched by the value of the `$term` parameter (in particular, 'name' and 'term_taxonomy_id' are now supported). Props sudar, mordauk. Fixes #14156. git-svn-id: https://develop.svn.wordpress.org/trunk@32553 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -54,6 +54,53 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase {
|
||||
|
||||
$term = (string) $t1;
|
||||
|
||||
$actual = get_term_link( $term, 'wptests_tax', 'id' );
|
||||
$this->assertContains( 'wptests_tax=foo', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 14156
|
||||
*/
|
||||
public function test_should_match_field_by_name() {
|
||||
$t = $this->factory->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Bar Term',
|
||||
) );
|
||||
|
||||
$actual = get_term_link( 'Bar Term', 'wptests_tax', 'name' );
|
||||
$this->assertContains( 'wptests_tax=foo', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 14156
|
||||
*/
|
||||
public function test_should_match_field_by_tt_id() {
|
||||
$t = $this->factory->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Bar Term',
|
||||
) );
|
||||
|
||||
$actual = get_term_link( 'Bar Term', 'wptests_tax', 'name' );
|
||||
$this->assertContains( 'wptests_tax=foo', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 14156
|
||||
*/
|
||||
public function test_numeric_string_should_be_interpreted_as_term_id_if_id_field_is_specified() {
|
||||
$t1 = $this->factory->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'name' => 'foo',
|
||||
) );
|
||||
$t2 = $this->factory->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'slug' => $t1,
|
||||
) );
|
||||
|
||||
$term = (string) $t1;
|
||||
|
||||
$actual = get_term_link( $term, 'wptests_tax' );
|
||||
$this->assertContains( 'wptests_tax=' . $term, $actual );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user