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/http/base.php

    r51331 r51397  
    256256        }
    257257
    258         $this->assertTrue( isset( $headers['test1'] ) && 'test' === $headers['test1'] );
    259         $this->assertTrue( isset( $headers['test2'] ) && '0' === $headers['test2'] );
     258        $this->assertArrayHasKey( 'test1', $headers );
     259        $this->assertSame( 'test', $headers['test1'] );
     260        $this->assertArrayHasKey( 'test2', $headers );
     261        $this->assertSame( '0', $headers['test2'] );
    260262        // cURL/HTTP Extension Note: Will never pass, cURL does not pass headers with an empty value.
    261263        // Should it be that empty headers with empty values are NOT sent?
    262         // $this->assertTrue( isset( $headers['test3'] ) && '' === $headers['test3'] );
     264        // $this->assertArrayHasKey( 'test3', $headers );
     265        // $this->assertSame( '', $headers['test3'] );
    263266    }
    264267
Note: See TracChangeset for help on using the changeset viewer.