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/user.php

    r51367 r51397  
    167167        // So we'll just check to make sure our values are included somewhere.
    168168        foreach ( $vals as $k => $v ) {
    169             $this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
     169            $this->assertArrayHasKey( $k, $out );
     170            $this->assertSame( $v, $out[ $k ][0] );
    170171        }
    171172        // Delete one key and check again.
     
    177178        foreach ( $vals as $k => $v ) {
    178179            if ( $k === $key_to_delete ) {
    179                 $this->assertFalse( isset( $out[ $k ] ) );
     180                $this->assertArrayNotHasKey( $k, $out );
    180181            } else {
    181                 $this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
     182                $this->assertArrayHasKey( $k, $out );
     183                $this->assertSame( $v, $out[ $k ][0] );
    182184            }
    183185        }
Note: See TracChangeset for help on using the changeset viewer.