category_description() should be taxonomy-agnostic.

This change reinstates the previous de facto behavior of `category_description()`.
See [40979], [42364]. Because `term_description()` no longer passes `$taxonomy` to
`get_term_field()`, the parameter is no longer needed and has been deprecated.

Fixes #42605. See #42771.

git-svn-id: https://develop.svn.wordpress.org/trunk@42368 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2017-12-04 21:48:24 +00:00
parent ffb86c0552
commit 2e5bbe0667
2 changed files with 82 additions and 5 deletions
@@ -0,0 +1,78 @@
<?php
/**
* @group taxonomy
* @covers ::category_description
*/
class Tests_Category_CategoryDescription extends WP_UnitTestCase {
public function test_success_query_by_id() {
$description = 'Foo';
$c = self::factory()->category->create( array(
'description' => $description,
) );
$found = category_description( $c );
$expected = apply_filters( 'term_description', $description );
$this->assertSame( $expected, $found );
}
public function test_success_query_by_object() {
$description = 'Foo';
$c = self::factory()->category->create( array(
'description' => $description,
'slug' => 'bar',
) );
$category = get_term( $c );
$found = category_description( $c );
$expected = apply_filters( 'term_description', $description );
$this->assertSame( $expected, $found );
}
/**
* @ticket 42605
* @ticket 42771
*/
public function test_should_return_description_for_term_from_another_taxonomy_on_primed_cache() {
register_taxonomy( 'wptests_tax', 'post' );
$description = 'Foo';
$t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'description' => $description,
) );
$term = get_term( $t );
$found = category_description( $t );
$expected = apply_filters( 'term_description', $description );
$this->assertSame( $expected, $found );
}
/**
* @ticket 42605
* @ticket 42771
*/
public function test_should_return_description_for_term_from_another_taxonomy_on_empty_cache() {
register_taxonomy( 'wptests_tax', 'post' );
$description = 'Foo';
$t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'description' => $description,
) );
clean_term_cache( $t );
$found = category_description( $t );
$expected = apply_filters( 'term_description', $description );
$this->assertSame( $expected, $found );
}
}