Make WordPress Core

#50236 closed enhancement (fixed)

Extend namespaced version of PHPUnit's test case class

Reported by: ocean90 Owned by: ocean90
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests
Focuses: Cc:


Now that WordPress requires at least PHP 5.6 we're also able to use namespaces.
PHPUnit uses namespaces which forced us to provide custom class aliases to make our tests compatible with PHPUnit 6 (and PHP 5.2), see #39822.

For running the tests on PHP 5.6 we're using PHPUnit 5 which should be our minimum supported version. Since PHPUnit\Framework\TestCase is already available in PHPUnit 5 it should be safe to replace it. The tests are still passing.

The change would solve autocompleting issues with editors which are not resolving the custom class aliases when you use PHPUnit 7 for example.

Change History (2)

This ticket was mentioned in PR #218 on WordPress/wordpress-develop by ocean90.

16 months ago

  • Keywords has-patch has-unit-tests added

#2 @ocean90
16 months ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 47880:

Build/Test Tools: Let WP_UnitTestCase_Base extend the namespaced version of PHPUnit's test case class.

With the minimum PHP version requirement set to 5.6 we're now able to use namespaces by default. This replaces PHPUnit_Framework_TestCase with PHPUnit\Framework\TestCase for WP_UnitTestCase_Base to solve autocompletion issues with code editors when using more recent PHPUnit versions. PHPUnit\Framework\TestCase is available since PHPUnit 5.4 and now the minimum required PHPUnit version.

Fixes #50236.

Note: See TracTickets for help on using tickets.