getCategoryLink.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * @group taxonomy
  4. * @covers ::get_category_link
  5. */
  6. class Tests_Category_GetCategoryLink extends WP_UnitTestCase {
  7. public function test_success() {
  8. $c = self::factory()->category->create();
  9. $found = get_category_link( $c );
  10. $expected = home_url( '?cat=' . $c );
  11. $this->assertSame( $expected, $found );
  12. }
  13. /**
  14. * @ticket 42771
  15. */
  16. public function test_should_return_link_for_term_from_another_taxonomy_on_primed_cache() {
  17. register_taxonomy( 'wptests_tax', 'post' );
  18. $t = self::factory()->term->create(
  19. array(
  20. 'taxonomy' => 'wptests_tax',
  21. 'slug' => 'test-term',
  22. )
  23. );
  24. $term = get_term( $t );
  25. $found = get_category_link( $t );
  26. $expected = home_url( '?wptests_tax=test-term' );
  27. $this->assertSame( $expected, $found );
  28. }
  29. /**
  30. * @ticket 42771
  31. */
  32. public function test_should_return_link_for_term_from_another_taxonomy_on_empty_cache() {
  33. register_taxonomy( 'wptests_tax', 'post' );
  34. $t = self::factory()->term->create(
  35. array(
  36. 'taxonomy' => 'wptests_tax',
  37. 'slug' => 'test-term',
  38. )
  39. );
  40. clean_term_cache( $t );
  41. $found = get_category_link( $t );
  42. $expected = home_url( '?wptests_tax=test-term' );
  43. $this->assertSame( $expected, $found );
  44. }
  45. }