WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#53491 closed defect (bug) (fixed)

update 'assertInternalType' is deprecate Method

Reported by: pbearne Owned by: SergeyBiryukov
Milestone: 5.9 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests commit
Focuses: Cc:

Description

patch to replace them

Attachments (1)

53491.diff (155.0 KB) - added by SergeyBiryukov 5 months ago.

Download all attachments as: .zip

Change History (9)

This ticket was mentioned in PR #1420 on WordPress/wordpress-develop by pbearne.


5 months ago

converted assertInternalType methods

Trac ticket: https://core.trac.wordpress.org/ticket/53491

#2 @desrosj
5 months ago

  • Milestone changed from Awaiting Review to 5.9

#3 @SergeyBiryukov
5 months ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#4 @SergeyBiryukov
5 months ago

  • Component changed from General to Build/Test Tools

#5 @SergeyBiryukov
5 months ago

Thanks for the PR!

It looks like assertIsArray(), assertIsString(), assertIsInt(), etc. are only available in PHPUnit 7.5.x or later, so we'll need polyfills for older versions. WordPress currently supports PHPUnit 5.4.x as the minimum version.

Related: #46149

#6 @SergeyBiryukov
5 months ago

  • Keywords commit added

53491.diff adds the polyfills for PHPUnit < 7.5.x and fixes some WPCS issues, making all the tests pass.

#7 @SergeyBiryukov
5 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 51331:

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.

This ticket was mentioned in Slack in #core by sergey. View the logs.


5 months ago

Note: See TracTickets for help on using tickets.