Make WordPress Core


Ignore:
Timestamp:
07/10/2021 11:15:44 AM (4 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/user/capabilities.php

    r50491 r51397  
    16091609
    16101610        $author->add_cap( 'foo', false );
    1611         $this->assertTrue( isset( $author->caps['foo'] ) );
     1611        $this->assertArrayHasKey( 'foo', $author->caps );
    16121612        $this->assertFalse( user_can( $author->ID, 'foo' ) );
    16131613
    16141614        $author->remove_cap( 'foo' );
    1615         $this->assertFalse( isset( $author->caps['foo'] ) );
     1615        $this->assertArrayNotHasKey( 'foo', $author->caps );
    16161616        $this->assertFalse( user_can( $author->ID, 'foo' ) );
    16171617    }
     
    22382238        $wp_roles->for_site( $site_id );
    22392239
    2240         $this->assertTrue( isset( $wp_roles->role_objects[ $role_name ] ) );
     2240        $this->assertArrayHasKey( $role_name, $wp_roles->role_objects );
    22412241    }
    22422242
Note: See TracChangeset for help on using the changeset viewer.