Changeset 55924 for trunk/tests/phpunit/tests/term/getTagLink.php
- Timestamp:
- 06/15/2023 03:23:25 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/getTagLink.php
r46586 r55924 6 6 */ 7 7 class Tests_Term_GetTagLink extends WP_UnitTestCase { 8 public function test_success() { 9 $t = self::factory()->term->create( 8 /** 9 * Tag ID. 10 * 11 * @var int 12 */ 13 public static $tag_id; 14 15 /** 16 * Test taxonomy term ID. 17 * 18 * @var int 19 */ 20 public static $term_id; 21 22 /** 23 * Set up shared fixtures. 24 * 25 * @param WP_UnitTest_Factory $factory 26 */ 27 public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 28 self::$tag_id = $factory->term->create( 10 29 array( 11 30 'taxonomy' => 'post_tag', 12 'slug' => 'te rm-slug',31 'slug' => 'test-tag', 13 32 ) 14 33 ); 15 34 16 $found = get_tag_link( $t ); 17 $expected = home_url( '?tag=term-slug' ); 35 register_taxonomy( 'wptests_tax', 'post' ); 36 self::$term_id = self::factory()->term->create( 37 array( 38 'taxonomy' => 'wptests_tax', 39 'slug' => 'test-term', 40 ) 41 ); 42 } 43 44 /** 45 * Set up the test fixture. 46 */ 47 public function set_up() { 48 parent::set_up(); 49 // Required as taxonomies are reset between tests. 50 register_taxonomy( 'wptests_tax', 'post' ); 51 } 52 53 public function test_success() { 54 $tag_id = self::$tag_id; 55 56 $found = get_tag_link( $tag_id ); 57 $expected = home_url( '?tag=test-tag' ); 18 58 19 59 $this->assertSame( $expected, $found ); … … 24 64 */ 25 65 public function test_should_return_link_for_term_from_another_taxonomy_on_primed_cache() { 26 register_taxonomy( 'wptests_tax', 'post' );66 $term_id = self::$term_id; 27 67 28 $t = self::factory()->term->create( 29 array( 30 'taxonomy' => 'wptests_tax', 31 'slug' => 'test-term', 32 ) 33 ); 68 $term = get_term( $term_id ); 34 69 35 $term = get_term( $t ); 36 37 $found = get_tag_link( $t ); 70 $found = get_tag_link( $term_id ); 38 71 $expected = home_url( '?wptests_tax=test-term' ); 39 72 … … 45 78 */ 46 79 public function test_should_return_link_for_term_from_another_taxonomy_on_empty_cache() { 47 register_taxonomy( 'wptests_tax', 'post' );80 $term_id = self::$term_id; 48 81 49 $t = self::factory()->term->create( 50 array( 51 'taxonomy' => 'wptests_tax', 52 'slug' => 'test-term', 53 ) 54 ); 82 clean_term_cache( $term_id ); 55 83 56 clean_term_cache( $t ); 57 58 $found = get_tag_link( $t ); 84 $found = get_tag_link( $term_id ); 59 85 $expected = home_url( '?wptests_tax=test-term' ); 60 86
Note: See TracChangeset
for help on using the changeset viewer.