Verified Commit 0e38c5f4 authored by Dave Long's avatar Dave Long
Browse files

Issue #3355795 by mondrake, smustgrave, Spokje:...

Issue #3355795 by mondrake, smustgrave, Spokje: Test::parseTestMethodAnnotations is removed in PHPUnit 10
parent cf174d10
Loading
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
use PHPUnit\Util\Test;

/**
 * Base class for tests of Migrate source plugins.
@@ -78,13 +77,9 @@ protected function setUp(): void {
   * @return string
   */
  protected function getPluginClass() {
    $annotations = Test::parseTestMethodAnnotations(
      static::class,
      $this->name()
    );

    if (isset($annotations['class']['covers'])) {
      return $annotations['class']['covers'][0];
    $covers = $this->getTestClassCovers();
    if (!empty($covers)) {
      return $covers[0];
    }
    else {
      $this->fail('No plugin class was specified');
+13 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@

namespace Drupal\TestTools\PhpUnitCompatibility\PhpUnit9;

use PHPUnit\Util\Test;

/**
 * Drupal's forward compatibility layer with multiple versions of PHPUnit.
 */
@@ -16,4 +18,15 @@ public function name(): string {
    return $this->getName();
  }

  /**
   * Gets @covers defined on the test class.
   *
   * @return string[]
   *   An array of classes listed with the @covers annotation.
   */
  public function getTestClassCovers(): array {
    $annotations = Test::parseTestMethodAnnotations(static::class, $this->name());
    return $annotations['class']['covers'] ?? [];
  }

}