WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/07/2021 10:32:56 AM (3 months 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/post/objects.php

    r51331 r51367  
    114114
    115115        $this->assertIsArray( $post->post_category );
    116         $this->assertSame( 1, count( $post->post_category ) );
     116        $this->assertCount( 1, $post->post_category );
    117117        $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] );
    118118        $term1 = wp_insert_term( 'Foo', 'category' );
     
    120120        $term3 = wp_insert_term( 'Baz', 'category' );
    121121        wp_set_post_categories( $post_id, array( $term1['term_id'], $term2['term_id'], $term3['term_id'] ) );
    122         $this->assertSame( 3, count( $post->post_category ) );
     122        $this->assertCount( 3, $post->post_category );
    123123        $this->assertSame( array( $term2['term_id'], $term3['term_id'], $term1['term_id'] ), $post->post_category );
    124124
    125125        $post = get_post( $post_id, ARRAY_A );
    126         $this->assertSame( 3, count( $post['post_category'] ) );
     126        $this->assertCount( 3, $post['post_category'] );
    127127        $this->assertSame( array( $term2['term_id'], $term3['term_id'], $term1['term_id'] ), $post['post_category'] );
    128128    }
     
    136136        wp_set_post_tags( $post_id, 'Foo, Bar, Baz' );
    137137        $this->assertIsArray( $post->tags_input );
    138         $this->assertSame( 3, count( $post->tags_input ) );
     138        $this->assertCount( 3, $post->tags_input );
    139139        $this->assertSame( array( 'Bar', 'Baz', 'Foo' ), $post->tags_input );
    140140
    141141        $post = get_post( $post_id, ARRAY_A );
    142142        $this->assertIsArray( $post['tags_input'] );
    143         $this->assertSame( 3, count( $post['tags_input'] ) );
     143        $this->assertCount( 3, $post['tags_input'] );
    144144        $this->assertSame( array( 'Bar', 'Baz', 'Foo' ), $post['tags_input'] );
    145145    }
Note: See TracChangeset for help on using the changeset viewer.