Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#50236 closed enhancement (fixed)

Extend namespaced version of PHPUnit's test case class

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

Description

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.


6 years ago
#1

  • Keywords has-patch has-unit-tests added

#2 @ocean90
6 years ago

  • Owner set to ocean90
  • Resolution → fixed
  • Status new → 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.