Make WordPress Core


Ignore:
Timestamp:
07/07/2021 10:32:56 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use more appropriate assertions in various tests.

This replaces instances of assertSame( [number], count( ... ) ) with assertCount() to use native PHPUnit functionality.

Follow-up to [51335], [51337].

See #53363.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/getTerms.php

    r51331 r51367  
    116116                // last_changed and num_queries should bump.
    117117                $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) );
    118                 $this->assertSame( 3, count( $terms ) );
     118                $this->assertCount( 3, $terms );
    119119                $time1 = wp_cache_get( 'last_changed', 'terms' );
    120120                $this->assertNotEmpty( $time1 );
    … …  
    125125                // Again. last_changed and num_queries should remain the same.
    126126                $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) );
    127                 $this->assertSame( 3, count( $terms ) );
     127                $this->assertCount( 3, $terms );
    128128                $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) );
    129129                $this->assertSame( $num_queries, $wpdb->num_queries );
    … …  
    145145                // num_queries should bump, last_changed should remain the same.
    146146                $terms = get_terms( 'post_tag', array( 'number' => 2 ) );
    147                 $this->assertSame( 2, count( $terms ) );
     147                $this->assertCount( 2, $terms );
    148148                $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) );
    149149                $this->assertSame( $num_queries + 1, $wpdb->num_queries );
    … …  
    153153                // Again. last_changed and num_queries should remain the same.
    154154                $terms = get_terms( 'post_tag', array( 'number' => 2 ) );
    155                 $this->assertSame( 2, count( $terms ) );
     155                $this->assertCount( 2, $terms );
    156156                $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) );
    157157                $this->assertSame( $num_queries, $wpdb->num_queries );
    … …  
    180180                // last_changed and num_queries should bump after a term is deleted.
    181181                $terms = get_terms( 'post_tag' );
    182                 $this->assertSame( 2, count( $terms ) );
     182                $this->assertCount( 2, $terms );
    183183                $this->assertSame( $time2, wp_cache_get( 'last_changed', 'terms' ) );
    184184                $this->assertSame( $num_queries + 1, $wpdb->num_queries );
    … …  
    188188                // Again. last_changed and num_queries should remain the same.
    189189                $terms = get_terms( 'post_tag' );
    190                 $this->assertSame( 2, count( $terms ) );
     190                $this->assertCount( 2, $terms );
    191191                $this->assertSame( $time2, wp_cache_get( 'last_changed', 'terms' ) );
    192192                $this->assertSame( $num_queries, $wpdb->num_queries );
    … …  
    618618                        )
    619619                );
    620                 $this->assertSame( 2, count( $terms ) );
     620                $this->assertCount( 2, $terms );
    621621                $this->assertSame( wp_list_pluck( $terms, 'name' ), array( 'Cheese', 'Crackers' ) );
    622622        }
    … …  
    661661                        )
    662662                );
    663                 $this->assertSame( 1, count( $terms ) );
     663                $this->assertCount( 1, $terms );
    664664                $this->assertSame( array( 'Cheese' ), wp_list_pluck( $terms, 'name' ) );
    665665
    … …  
    697697                        )
    698698                );
    699                 $this->assertSame( 1, count( $terms ) );
     699                $this->assertCount( 1, $terms );
    700700                $this->assertSame( array( 'term1' ), wp_list_pluck( $terms, 'name' ) );
    701701
    … …  
    717717                        )
    718718                );
    719                 $this->assertSame( 1, count( $terms ) );
     719                $this->assertCount( 1, $terms );
    720720        }
    721721
    … …  
    23092309
    23102310                // Verify that there are no children.
    2311                 $this->assertSame( 0, count( $terms ) );
     2311                $this->assertCount( 0, $terms );
    23122312        }
    23132313
    … …  
    23752375
    23762376                // Verify that there are no children.
    2377                 $this->assertSame( 0, count( $terms ) );
     2377                $this->assertCount( 0, $terms );
    23782378        }
    23792379
    … …  
    24882488
    24892489                // 'hierarchical=false' means that descendants are not fetched.
    2490                 $this->assertSame( 0, count( $terms ) );
     2490                $this->assertCount( 0, $terms );
    24912491        }
    24922492
Note: See TracChangeset for help on using the changeset viewer.