Changeset 47122 for trunk/tests/phpunit/tests/term/getTerms.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/term/getTerms.php (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/getTerms.php
r46586 r47122 114 114 $num_queries = $wpdb->num_queries; 115 115 116 // last_changed and num_queries should bump 116 // last_changed and num_queries should bump. 117 117 $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) ); 118 118 $this->assertEquals( 3, count( $terms ) ); … … 138 138 $this->set_up_three_posts_and_tags(); 139 139 140 // Prime cache 140 // Prime cache. 141 141 $terms = get_terms( 'post_tag' ); 142 142 $time1 = wp_cache_get( 'last_changed', 'terms' ); … … 166 166 $this->set_up_three_posts_and_tags(); 167 167 168 // Prime cache 168 // Prime cache. 169 169 $terms = get_terms( 'post_tag' ); 170 170 $time1 = wp_cache_get( 'last_changed', 'terms' ); … … 776 776 */ 777 777 function test_get_term_children_recursion() { 778 // Assume there is a way to insert a term with the parent pointing to itself 778 // Assume there is a way to insert a term with the parent pointing to itself. 779 779 // See: https://core.trac.wordpress.org/changeset/15806 780 780 remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 ); … … 927 927 $this->assertEqualSets( array( $t ), $found ); 928 928 929 // array format.929 // Array format. 930 930 $found = get_terms( 931 931 'wptests_tax', … … 1026 1026 PEI 1027 1027 */ 1028 // Level 1 1028 // Level 1. 1029 1029 $canada = self::factory()->term->create( 1030 1030 array( … … 1034 1034 ); 1035 1035 1036 // Level 2 1036 // Level 2. 1037 1037 $ontario = self::factory()->term->create( 1038 1038 array( … … 1057 1057 ); 1058 1058 1059 // Level 3 1059 // Level 3. 1060 1060 $toronto = self::factory()->term->create( 1061 1061 array( … … 1080 1080 ); 1081 1081 1082 // Level 4 1082 // Level 4. 1083 1083 $nepean = self::factory()->term->create( 1084 1084 array( … … 1108 1108 register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) ); 1109 1109 1110 // Level 1 1110 // Level 1. 1111 1111 $canada = self::factory()->term->create( 1112 1112 array( … … 1116 1116 ); 1117 1117 1118 // Level 2 1118 // Level 2. 1119 1119 $ontario = self::factory()->term->create( 1120 1120 array( … … 1132 1132 ); 1133 1133 1134 // Level 3 1134 // Level 3. 1135 1135 $laval = self::factory()->term->create( 1136 1136 array( … … 1148 1148 ); 1149 1149 1150 // Level 4 1150 // Level 4. 1151 1151 $dorval = self::factory()->term->create( 1152 1152 array( … … 2222 2222 $initial_terms = $this->create_hierarchical_terms(); 2223 2223 2224 // Case where hierarchical is false 2224 // Case where hierarchical is false. 2225 2225 $terms = get_terms( 2226 2226 'category', … … 2231 2231 ); 2232 2232 2233 // Verify that there are no children 2233 // Verify that there are no children. 2234 2234 $this->assertEquals( 0, count( $terms ) ); 2235 2235 } … … 2241 2241 $initial_terms = $this->create_hierarchical_terms(); 2242 2242 2243 // Case where hierarchical is true 2243 // Case where hierarchical is true. 2244 2244 $terms = get_terms( 2245 2245 'category', … … 2250 2250 ); 2251 2251 2252 // Verify that the children with non-empty descendants are returned 2252 // Verify that the children with non-empty descendants are returned. 2253 2253 $expected = array( 2254 2254 $initial_terms['two_term']['term_id'], … … 2268 2268 ); 2269 2269 2270 // Case where hierarchical is false 2270 // Case where hierarchical is false. 2271 2271 $terms = get_terms( 2272 2272 'category', … … 2288 2288 $initial_terms = $this->create_hierarchical_terms(); 2289 2289 2290 // Case where hierarchical is false 2290 // Case where hierarchical is false. 2291 2291 $terms = get_terms( 2292 2292 'category', … … 2297 2297 ); 2298 2298 2299 // Verify that there are no children 2299 // Verify that there are no children. 2300 2300 $this->assertEquals( 0, count( $terms ) ); 2301 2301 } … … 2304 2304 $initial_terms = $this->create_hierarchical_terms(); 2305 2305 2306 // Case where hierarchical is true 2306 // Case where hierarchical is true. 2307 2307 $terms = get_terms( 2308 2308 'category', … … 2400 2400 $initial_terms = $this->create_hierarchical_terms(); 2401 2401 2402 // Case where hierarchical is false 2402 // Case where hierarchical is false. 2403 2403 $terms = get_terms( 2404 2404 'category', … … 2410 2410 ); 2411 2411 2412 // hierarchical=falsemeans that descendants are not fetched.2412 // 'hierarchical=false' means that descendants are not fetched. 2413 2413 $this->assertEquals( 0, count( $terms ) ); 2414 2414 } … … 2420 2420 $initial_terms = $this->create_hierarchical_terms(); 2421 2421 2422 // Case where hierarchical is true 2422 // Case where hierarchical is true. 2423 2423 $terms = get_terms( 2424 2424 'category', … … 2430 2430 ); 2431 2431 2432 // Verify that parent takes precedence over child_of 2432 // Verify that parent takes precedence over child_of. 2433 2433 $expected = array( 2434 2434 $initial_terms['two_term']['term_id'], … … 2998 2998 2999 2999 protected function create_hierarchical_terms() { 3000 // Set up the following hierarchy: 3001 // - One 3002 // - Two 3003 // - Three (1) 3004 // - Four 3005 // - Five 3006 // - Six (1) 3007 // - Seven 3000 /* 3001 * Set up the following hierarchy: 3002 * - One 3003 * - Two 3004 * - Three (1) 3005 * - Four 3006 * - Five 3007 * - Six (1) 3008 * - Seven 3009 */ 3008 3010 $one_term = wp_insert_term( 3009 3011 'One', … … 3053 3055 ); 3054 3056 3055 // Ensure child terms are not empty 3057 // Ensure child terms are not empty. 3056 3058 $first_post_id = self::factory()->post->create(); 3057 3059 $second_post_id = self::factory()->post->create();
Note: See TracChangeset
for help on using the changeset viewer.