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/post/types.php

    r51367 r51397  
    395395        $this->assertTrue( unregister_post_type( 'foo' ) );
    396396
    397         $this->assertFalse( isset( $post_type_meta_caps['read_bar'] ) );
    398         $this->assertFalse( isset( $post_type_meta_caps['delete_bar'] ) );
    399         $this->assertFalse( isset( $post_type_meta_caps['edit_bar'] ) );
     397        $this->assertArrayNotHasKey( 'read_bar', $post_type_meta_caps );
     398        $this->assertArrayNotHasKey( 'delete_bar', $post_type_meta_caps );
     399        $this->assertArrayNotHasKey( 'edit_bar', $post_type_meta_caps );
    400400    }
    401401
     
    423423        );
    424424        $this->assertTrue( unregister_post_type( 'foo' ) );
    425         $this->assertFalse( isset( $_wp_post_type_features['foo'] ) );
     425        $this->assertArrayNotHasKey( 'foo', $_wp_post_type_features );
    426426    }
    427427
     
    505505        $this->assertTrue( unregister_post_type( 'foo' ) );
    506506
    507         $this->assertFalse( isset( $wp_post_types['foo'] ) );
     507        $this->assertArrayNotHasKey( 'foo', $wp_post_types );
    508508        $this->assertNull( get_post_type_object( 'foo' ) );
    509509    }
Note: See TracChangeset for help on using the changeset viewer.