Fix regression in get_tag_link() since 4.9.

See [42364] for description of the problem.

Because `get_category_link()` is now totally taxonomy-agnostic, `get_tag_link()`
can become a simple wrapper.

Props juiiee8487, markjaquith.
See #42771.

git-svn-id: https://develop.svn.wordpress.org/trunk@42366 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2017-12-04 20:51:27 +00:00
parent 829d8bb179
commit 8951af66d4
2 changed files with 58 additions and 11 deletions
+57
View File
@@ -0,0 +1,57 @@
<?php
/**
* @group taxonomy
* @covers ::get_tag_link
*/
class Tests_Term_GetTagLink extends WP_UnitTestCase {
public function test_success() {
$t = self::factory()->term->create( array(
'taxonomy' => 'post_tag',
'slug' => 'term-slug',
) );
$found = get_tag_link( $t );
$expected = home_url( '?tag=term-slug' );
$this->assertSame( $expected, $found );
}
/**
* @ticket 42771
*/
public function test_should_return_link_for_term_from_another_taxonomy_on_primed_cache() {
register_taxonomy( 'wptests_tax', 'post' );
$t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'slug' => 'test-term',
) );
$term = get_term( $t );
$found = get_tag_link( $t );
$expected = home_url( '?wptests_tax=test-term' );
$this->assertSame( $expected, $found );
}
/**
* @ticket 42771
*/
public function test_should_return_link_for_term_from_another_taxonomy_on_empty_cache() {
register_taxonomy( 'wptests_tax', 'post' );
$t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'slug' => 'test-term',
) );
clean_term_cache( $t );
$found = get_tag_link( $t );
$expected = home_url( '?wptests_tax=test-term' );
$this->assertSame( $expected, $found );
}
}