Changeset 53836 for trunk/tests/phpunit/tests/link/editTermLink.php
- Timestamp:
- 08/04/2022 06:28:33 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/link/editTermLink.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/link/editTermLink.php
r53833 r53836 13 13 self::register_custom_taxonomy(); 14 14 15 $taxonomies = array( 'category', 'post_tag', ' custom_taxonomy' );15 $taxonomies = array( 'category', 'post_tag', 'wptests_tax' ); 16 16 foreach ( $taxonomies as $taxonomy ) { 17 17 self::$terms[ $taxonomy ] = $factory->term->create_and_get( array( 'taxonomy' => $taxonomy ) ); … … 24 24 public function set_up() { 25 25 parent::set_up(); 26 wp_set_current_user( self::$user_ids['admin'] ); 26 27 self::register_custom_taxonomy(); 28 } 29 30 /** 31 * Helper to register a custom taxonomy for use in tests. 32 * 33 * @since 5.9.0 34 */ 35 private static function register_custom_taxonomy() { 36 register_taxonomy( 'wptests_tax', 'post' ); 37 } 38 39 /** 40 * Helper to get the term for the given taxonomy. 41 * 42 * @since 5.9.0 43 * 44 * @param string $taxonomy Taxonomy being tested (used for index of term keys). 45 * @param bool $use_id When true, pass term ID. Else, pass term object. 46 * @return WP_Term|int If $use_id is true, term ID is returned; else instance of WP_Term. 47 */ 48 private function get_term( $taxonomy, $use_id ) { 49 $term = self::$terms[ $taxonomy ]; 50 if ( $use_id ) { 51 $term = $term->term_id; 52 } 53 54 return $term; 27 55 } 28 56 … … 37 65 */ 38 66 public function test_edit_term_link_for_permitted_user( $taxonomy, $use_id, $expected ) { 39 wp_set_current_user( self::$user_ids['admin'] );40 67 $term = $this->get_term( $taxonomy, $use_id ); 41 68 … … 73 100 */ 74 101 public function test_edit_term_link_filter_is_int_by_term_id( $taxonomy, $use_id ) { 75 wp_set_current_user( self::$user_ids['admin'] );76 102 $term = $this->get_term( $taxonomy, $use_id ); 77 103 … … 97 123 */ 98 124 public function test_edit_term_link_filter_is_int_by_term_object( $taxonomy, $use_id ) { 99 wp_set_current_user( self::$user_ids['admin'] );100 125 $term = $this->get_term( $taxonomy, $use_id ); 101 126 … … 140 165 ), 141 166 'a custom taxonomy passing term_id' => array( 142 'taxonomy' => ' custom_taxonomy',167 'taxonomy' => 'wptests_tax', 143 168 'use_id' => true, 144 'expected' => 'term.php?taxonomy= custom_taxonomy&tag_ID=%ID%&post_type=post',169 'expected' => 'term.php?taxonomy=wptests_tax&tag_ID=%ID%&post_type=post', 145 170 ), 146 171 'a custom taxonomy passing term object' => array( 147 'taxonomy' => ' custom_taxonomy',172 'taxonomy' => 'wptests_tax', 148 173 'use_id' => false, 149 'expected' => 'term.php?taxonomy= custom_taxonomy&tag_ID=%ID%&post_type=post',174 'expected' => 'term.php?taxonomy=wptests_tax&tag_ID=%ID%&post_type=post', 150 175 ), 151 176 ); 152 177 } 153 154 /**155 * Helper to register a custom taxonomy for use in tests.156 *157 * @since 5.9.0158 */159 private static function register_custom_taxonomy() {160 register_taxonomy( 'custom_taxonomy', 'post' );161 }162 163 /**164 * Helper to get the term for the given taxonomy.165 *166 * @since 5.9.0167 *168 * @param string $taxonomy Taxonomy being tested (used for index of term keys).169 * @param bool $use_id When true, pass term ID. Else, pass term object.170 * @return WP_Term|int If $use_id is true, term ID is returned; else instance of WP_Term.171 */172 private function get_term( $taxonomy, $use_id ) {173 $term = self::$terms[ $taxonomy ];174 if ( $use_id ) {175 $term = $term->term_id;176 }177 178 return $term;179 }180 178 }
Note: See TracChangeset
for help on using the changeset viewer.