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/rest-api/rest-attachments-controller.php

    r51331 r51367  
    416416        $request  = new WP_REST_Request( 'GET', '/wp/v2/media' );
    417417        $response = rest_get_server()->dispatch( $request );
    418         $this->assertSame( 2, count( $response->get_data() ) );
     418        $this->assertCount( 2, $response->get_data() );
    419419        $request = new WP_REST_Request( 'GET', '/wp/v2/media' );
    420420        // Attachments without a parent.
     
    422422        $response = rest_get_server()->dispatch( $request );
    423423        $data     = $response->get_data();
    424         $this->assertSame( 1, count( $data ) );
     424        $this->assertCount( 1, $data );
    425425        $this->assertSame( $attachment_id2, $data[0]['id'] );
    426426        // Attachments with parent=post_id.
     
    429429        $response = rest_get_server()->dispatch( $request );
    430430        $data     = $response->get_data();
    431         $this->assertSame( 1, count( $data ) );
     431        $this->assertCount( 1, $data );
    432432        $this->assertSame( $attachment_id, $data[0]['id'] );
    433433        // Attachments with invalid parent.
     
    436436        $response = rest_get_server()->dispatch( $request );
    437437        $data     = $response->get_data();
    438         $this->assertSame( 0, count( $data ) );
     438        $this->assertCount( 0, $data );
    439439    }
    440440
     
    510510        $this->assertSame( 200, $response->get_status() );
    511511        $data = $response->get_data();
    512         $this->assertSame( 2, count( $data ) );
     512        $this->assertCount( 2, $data );
    513513        $ids = array(
    514514            $data[0]['id'],
     
    14661466        $data       = $response->get_data();
    14671467        $properties = $data['schema']['properties'];
    1468         $this->assertSame( 27, count( $properties ) );
     1468        $this->assertCount( 27, $properties );
    14691469        $this->assertArrayHasKey( 'author', $properties );
    14701470        $this->assertArrayHasKey( 'alt_text', $properties );
Note: See TracChangeset for help on using the changeset viewer.