Make WordPress Core


Ignore:
Timestamp:
07/05/2021 05:21:53 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Build/Test Tools: Replace assertInternalType() usage in unit tests.

The assertInternalType() and assertNotInternalType() methods are deprecated in PHPUnit 8 and removed in PHPUnit 9.

While WordPress test suite currently only supports PHPUnit up to 7.5.x, this allows us to switch to newer assertions ahead of adding full support for PHPUnit 8+.

These methods introduced in PHPUnit 7.5 should be used as an alternative:

  • assertIsArray()
  • assertIsBool()
  • assertIsFloat()
  • assertIsInt()
  • assertIsNumeric()
  • assertIsObject()
  • assertIsResource()
  • assertIsString()
  • assertIsScalar()
  • assertIsCallable()
  • assertIsIterable()
  • assertIsNotArray()
  • assertIsNotBool()
  • assertIsNotFloat()
  • assertIsNotInt()
  • assertIsNotNumeric()
  • assertIsNotObject()
  • assertIsNotResource()
  • assertIsNotString()
  • assertIsNotScalar()
  • assertIsNotCallable()
  • assertIsNotIterable()

As WordPress currently uses PHPUnit 5.7.x to run tests on PHP 5.6, polyfills for these methods are now added to the WP_UnitTestCase class for PHPUnit < 7.5.

Props pbearne, jrf, dd32, SergeyBiryukov.
Fixes #53491. See #46149.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/http/functions.php

    r51300 r51331  
    2020        $headers = wp_remote_retrieve_headers( $response );
    2121
    22         $this->assertInternalType( 'array', $response );
     22        $this->assertIsArray( $response );
    2323
    2424        $this->assertSame( 'image/jpeg', $headers['content-type'] );
     
    6464        $headers = wp_remote_retrieve_headers( $response );
    6565
    66         $this->assertInternalType( 'array', $response );
     66        $this->assertIsArray( $response );
    6767
    6868        // Should return the same headers as a HEAD request.
Note: See TracChangeset for help on using the changeset viewer.