Changeset 48937 for trunk/tests/phpunit/tests/term/getTerms.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/getTerms.php
r48663 r48937 116 116 // last_changed and num_queries should bump. 117 117 $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) ); 118 $this->assert Equals( 3, count( $terms ) );118 $this->assertSame( 3, count( $terms ) ); 119 119 $time1 = wp_cache_get( 'last_changed', 'terms' ); 120 120 $this->assertNotEmpty( $time1 ); 121 $this->assert Equals( $num_queries + 1, $wpdb->num_queries );121 $this->assertSame( $num_queries + 1, $wpdb->num_queries ); 122 122 123 123 $num_queries = $wpdb->num_queries; … … 125 125 // Again. last_changed and num_queries should remain the same. 126 126 $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) ); 127 $this->assert Equals( 3, count( $terms ) );128 $this->assert Equals( $time1, wp_cache_get( 'last_changed', 'terms' ) );129 $this->assert Equals( $num_queries, $wpdb->num_queries );127 $this->assertSame( 3, count( $terms ) ); 128 $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) ); 129 $this->assertSame( $num_queries, $wpdb->num_queries ); 130 130 } 131 131 … … 145 145 // num_queries should bump, last_changed should remain the same. 146 146 $terms = get_terms( 'post_tag', array( 'number' => 2 ) ); 147 $this->assert Equals( 2, count( $terms ) );148 $this->assert Equals( $time1, wp_cache_get( 'last_changed', 'terms' ) );149 $this->assert Equals( $num_queries + 1, $wpdb->num_queries );147 $this->assertSame( 2, count( $terms ) ); 148 $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) ); 149 $this->assertSame( $num_queries + 1, $wpdb->num_queries ); 150 150 151 151 $num_queries = $wpdb->num_queries; … … 153 153 // Again. last_changed and num_queries should remain the same. 154 154 $terms = get_terms( 'post_tag', array( 'number' => 2 ) ); 155 $this->assert Equals( 2, count( $terms ) );156 $this->assert Equals( $time1, wp_cache_get( 'last_changed', 'terms' ) );157 $this->assert Equals( $num_queries, $wpdb->num_queries );155 $this->assertSame( 2, count( $terms ) ); 156 $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) ); 157 $this->assertSame( $num_queries, $wpdb->num_queries ); 158 158 } 159 159 … … 180 180 // last_changed and num_queries should bump after a term is deleted. 181 181 $terms = get_terms( 'post_tag' ); 182 $this->assert Equals( 2, count( $terms ) );183 $this->assert Equals( $time2, wp_cache_get( 'last_changed', 'terms' ) );184 $this->assert Equals( $num_queries + 1, $wpdb->num_queries );182 $this->assertSame( 2, count( $terms ) ); 183 $this->assertSame( $time2, wp_cache_get( 'last_changed', 'terms' ) ); 184 $this->assertSame( $num_queries + 1, $wpdb->num_queries ); 185 185 186 186 $num_queries = $wpdb->num_queries; … … 188 188 // Again. last_changed and num_queries should remain the same. 189 189 $terms = get_terms( 'post_tag' ); 190 $this->assert Equals( 2, count( $terms ) );191 $this->assert Equals( $time2, wp_cache_get( 'last_changed', 'terms' ) );192 $this->assert Equals( $num_queries, $wpdb->num_queries );190 $this->assertSame( 2, count( $terms ) ); 191 $this->assertSame( $time2, wp_cache_get( 'last_changed', 'terms' ) ); 192 $this->assertSame( $num_queries, $wpdb->num_queries ); 193 193 194 194 // @todo Repeat with term insert and update. … … 201 201 $term_id = self::factory()->tag->create(); 202 202 $terms = get_terms( array( '111' => 'post_tag' ), array( 'hide_empty' => false ) ); 203 $this->assert Equals( $term_id, reset( $terms )->term_id );203 $this->assertSame( $term_id, reset( $terms )->term_id ); 204 204 } 205 205 … … 301 301 ) 302 302 ); 303 $this->assert Equals( array( $term_id1, $term_id2 ), wp_list_pluck( $inc_terms, 'term_id' ) );303 $this->assertSame( array( $term_id1, $term_id2 ), wp_list_pluck( $inc_terms, 'term_id' ) ); 304 304 305 305 $exc_terms = get_terms( … … 310 310 ) 311 311 ); 312 $this->assert Equals( array(), wp_list_pluck( $exc_terms, 'term_id' ) );312 $this->assertSame( array(), wp_list_pluck( $exc_terms, 'term_id' ) ); 313 313 314 314 // These should not generate query errors. … … 364 364 ); 365 365 366 $this->assert Equals( array( $terms[1] ), wp_list_pluck( $found, 'term_id' ) );366 $this->assertSame( array( $terms[1] ), wp_list_pluck( $found, 'term_id' ) ); 367 367 368 368 _unregister_taxonomy( 'wptests_tax' ); … … 389 389 ) 390 390 ); 391 $this->assert Equals( array( $term_id1, $term_id11, $term_id2, $term_id22 ), $terms );391 $this->assertSame( array( $term_id1, $term_id11, $term_id2, $term_id22 ), $terms ); 392 392 393 393 $terms = get_terms( … … 400 400 ); 401 401 402 $this->assert Equals( array( $term_id2, $term_id22 ), $terms );402 $this->assertSame( array( $term_id2, $term_id22 ), $terms ); 403 403 404 404 } … … 548 548 } 549 549 $term = get_term( $cheddar, $tax ); 550 $this->assert Equals( 2, $term->count );550 $this->assertSame( 2, $term->count ); 551 551 552 552 $brie = self::factory()->term->create( … … 560 560 wp_set_post_terms( $post_id, $brie, $tax ); 561 561 $term = get_term( $brie, $tax ); 562 $this->assert Equals( 1, $term->count );562 $this->assertSame( 1, $term->count ); 563 563 564 564 $crackers = self::factory()->term->create( … … 581 581 } 582 582 $term = get_term( $butter, $tax ); 583 $this->assert Equals( 1, $term->count );583 $this->assertSame( 1, $term->count ); 584 584 585 585 $multigrain = self::factory()->term->create( … … 595 595 } 596 596 $term = get_term( $multigrain, $tax ); 597 $this->assert Equals( 1, $term->count );597 $this->assertSame( 1, $term->count ); 598 598 599 599 $fruit = self::factory()->term->create( … … 618 618 ) 619 619 ); 620 $this->assert Equals( 2, count( $terms ) );621 $this->assert Equals( wp_list_pluck( $terms, 'name' ), array( 'Cheese', 'Crackers' ) );620 $this->assertSame( 2, count( $terms ) ); 621 $this->assertSame( wp_list_pluck( $terms, 'name' ), array( 'Cheese', 'Crackers' ) ); 622 622 } 623 623 … … 652 652 wp_set_post_terms( $post_id, $spread, $tax ); 653 653 $term = get_term( $spread, $tax ); 654 $this->assert Equals( 1, $term->count );654 $this->assertSame( 1, $term->count ); 655 655 656 656 $terms = get_terms( … … 661 661 ) 662 662 ); 663 $this->assert Equals( 1, count( $terms ) );664 $this->assert Equals( array( 'Cheese' ), wp_list_pluck( $terms, 'name' ) );663 $this->assertSame( 1, count( $terms ) ); 664 $this->assertSame( array( 'Cheese' ), wp_list_pluck( $terms, 'name' ) ); 665 665 666 666 _unregister_taxonomy( $tax ); … … 688 688 wp_set_post_terms( $post_id, $t[7], $tax ); 689 689 $term = get_term( $t[7], $tax ); 690 $this->assert Equals( 1, $term->count );690 $this->assertSame( 1, $term->count ); 691 691 692 692 $terms = get_terms( … … 697 697 ) 698 698 ); 699 $this->assert Equals( 1, count( $terms ) );700 $this->assert Equals( array( 'term1' ), wp_list_pluck( $terms, 'name' ) );699 $this->assertSame( 1, count( $terms ) ); 700 $this->assertSame( array( 'term1' ), wp_list_pluck( $terms, 'name' ) ); 701 701 702 702 _unregister_taxonomy( $tax ); … … 717 717 ) 718 718 ); 719 $this->assert Equals( 1, count( $terms ) );719 $this->assertSame( 1, count( $terms ) ); 720 720 } 721 721 … … 749 749 ); 750 750 751 $this->assert Equals(751 $this->assertSame( 752 752 array( 753 753 $child => 'Test 1', … … 788 788 ); 789 789 790 $this->assert Equals(790 $this->assertSame( 791 791 array( 792 792 $child => 'test-1', … … 861 861 $term = get_term( $term['term_id'], 'category' ); 862 862 863 $this->assert Equals( $term->term_id, $term->parent );863 $this->assertSame( $term->term_id, $term->parent ); 864 864 $this->assertInternalType( 'array', get_term_children( $term->term_id, 'category' ) ); 865 865 … … 918 918 ); 919 919 920 $this->assert Equals( array( $t1 ), $found );920 $this->assertSame( array( $t1 ), $found ); 921 921 } 922 922 … … 938 938 ); 939 939 940 $this->assert Equals( array( $t1, $t3 ), $found );940 $this->assertSame( array( $t1, $t3 ), $found ); 941 941 } 942 942 … … 957 957 ); 958 958 959 $this->assert Equals( array( $t1 ), $found );959 $this->assertSame( array( $t1 ), $found ); 960 960 } 961 961 … … 1838 1838 _unregister_taxonomy( 'wptests_tax' ); 1839 1839 1840 $this->assert Equals( array( $t4, $t1, $t2 ), $found );1840 $this->assertSame( array( $t4, $t1, $t2 ), $found ); 1841 1841 } 1842 1842 … … 1884 1884 _unregister_taxonomy( 'wptests_tax' ); 1885 1885 1886 $this->assert Equals( array( $t2, $t1, $t4, $t3 ), $found );1886 $this->assertSame( array( $t2, $t1, $t4, $t3 ), $found ); 1887 1887 } 1888 1888 … … 1920 1920 ); 1921 1921 1922 $this->assert Equals( array( $t1, $t2, $t3 ), $found );1922 $this->assertSame( array( $t1, $t2, $t3 ), $found ); 1923 1923 } 1924 1924 … … 2309 2309 2310 2310 // Verify that there are no children. 2311 $this->assert Equals( 0, count( $terms ) );2311 $this->assertSame( 0, count( $terms ) ); 2312 2312 } 2313 2313 … … 2375 2375 2376 2376 // Verify that there are no children. 2377 $this->assert Equals( 0, count( $terms ) );2377 $this->assertSame( 0, count( $terms ) ); 2378 2378 } 2379 2379 … … 2488 2488 2489 2489 // 'hierarchical=false' means that descendants are not fetched. 2490 $this->assert Equals( 0, count( $terms ) );2490 $this->assertSame( 0, count( $terms ) ); 2491 2491 } 2492 2492 … … 2627 2627 foreach ( $found as $f ) { 2628 2628 if ( $t1 === $f->term_id ) { 2629 $this->assert Equals( 1, $f->count );2629 $this->assertSame( 1, $f->count ); 2630 2630 } elseif ( $t2 === $f->term_id ) { 2631 $this->assert Equals( 2, $f->count );2631 $this->assertSame( 2, $f->count ); 2632 2632 } else { 2633 $this->assert Equals( 1, $f->count );2633 $this->assertSame( 1, $f->count ); 2634 2634 } 2635 2635 }
Note: See TracChangeset
for help on using the changeset viewer.