Make WordPress Core


Ignore:
Timestamp:
07/10/2021 11:15:44 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use more appropriate assertions in various tests.

This replaces instances of assertTrue( isset( ... ) ) with assertArrayHasKey() to use native PHPUnit functionality.

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

See #53363.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r51367 r51397  
    692692
    693693        $this->assertIsArray( $data['media_details']['sizes'], 'Could not retrieve the sizes data.' );
    694         $this->assertFalse( isset( $data['media_details']['sizes']['rest-api-test']['source_url'] ) );
     694        $this->assertArrayNotHasKey( 'source_url', $data['media_details']['sizes']['rest-api-test'] );
    695695    }
    696696
     
    16871687            $this->assertSame( $attachment->post_content, $data['description']['raw'] );
    16881688        } else {
    1689             $this->assertFalse( isset( $data['caption']['raw'] ) );
    1690             $this->assertFalse( isset( $data['description']['raw'] ) );
     1689            $this->assertArrayNotHasKey( 'raw', $data['caption'] );
     1690            $this->assertArrayNotHasKey( 'raw', $data['description'] );
    16911691        }
    1692         $this->assertTrue( isset( $data['media_details'] ) );
     1692        $this->assertArrayHasKey( 'media_details', $data );
    16931693
    16941694        if ( $attachment->post_parent ) {
Note: See TracChangeset for help on using the changeset viewer.