mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Build/Test Tools: Handle removal of TestCase::getAnnotations().
The PHPUnit native `TestCase::getAnnotations()` method is used to check for WP flavored deprecation notices, however, this method was not covered by the backward compatibility promise for PHPUnit (and was annotated as excluded).
The method has been removed as part of an internal refactor in commit [68582043e1 sebastianbergmann/phpunit@6858204], which is included in PHPUnit 9.5.0.
For now, a workaround is put in place, but it is recommended that the WP `expectDeprecated()` method should be reevaluated in a future iteration.
Follow-up to [51559-51571].
Props jrf.
See #46149.
git-svn-id: https://develop.svn.wordpress.org/trunk@51572 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -472,7 +472,17 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
|
||||
* Sets up the expectations for testing a deprecated call.
|
||||
*/
|
||||
public function expectDeprecated() {
|
||||
$annotations = $this->getAnnotations();
|
||||
if ( method_exists( $this, 'getAnnotations' ) ) {
|
||||
// PHPUnit < 9.5.0.
|
||||
$annotations = $this->getAnnotations();
|
||||
} else {
|
||||
// PHPUnit >= 9.5.0.
|
||||
$annotations = \PHPUnit\Util\Test::parseTestMethodAnnotations(
|
||||
static::class,
|
||||
$this->getName( false )
|
||||
);
|
||||
}
|
||||
|
||||
foreach ( array( 'class', 'method' ) as $depth ) {
|
||||
if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) {
|
||||
$this->expected_deprecated = array_merge( $this->expected_deprecated, $annotations[ $depth ]['expectedDeprecated'] );
|
||||
|
||||
Reference in New Issue
Block a user