parseTestMethodAnnotations example

$this->prophesize(MigrateIdMapInterface::class)->reveal()
    );
    $this->migration->getDestinationIds()->willReturn([]);
  }

  /** * Determines the plugin to be tested by reading the class @covers annotation. * * @return string */
  protected function getPluginClass() {
    $annotations = Test::parseTestMethodAnnotations(
      static::class,
      $this->getName()
    );

    if (isset($annotations['class']['covers'])) {
      return $annotations['class']['covers'][0];
    }
    else {
      $this->fail('No plugin class was specified');
    }
  }

  
static::class,
      $this->getName(FALSE)
    );

    if (!empty($missingRequirements)) {
      $this->markTestSkipped(implode(PHP_EOL, $missingRequirements));
    }

    $root = static::getDrupalRoot();

    // Check if required dependencies exist.     $annotations = Test::parseTestMethodAnnotations(
      static::class,
      $this->getName()
    );
    if (!empty($annotations['class']['requires'])) {
      $this->checkModuleRequirements($root$annotations['class']['requires']);
    }
    if (!empty($annotations['method']['requires'])) {
      $this->checkModuleRequirements($root$annotations['method']['requires']);
    }
  }

  

  private static $existingCommands = [];

  /** * Checks whether required external commands are available per test class. * * @throws \PHPUnit\Framework\SkippedTestError * Thrown when the requirements are not met, and this test should be * skipped. Callers should not catch this exception. */
  private static function checkClassCommandRequirements() {
    $annotations = Test::parseTestMethodAnnotations(static::class);
    if (!empty($annotations['class']['requires'])) {
      static::checkExternalCommandRequirements($annotations['class']['requires']);
    }
  }

  /** * Checks whether required external commands are available per method. * * @throws \PHPUnit\Framework\SkippedTestError * Thrown when the requirements are not met, and this test should be * skipped. Callers should not catch this exception. */
ClockMock::withClockMock(true);
                }
                if (\in_array('dns-sensitive', $groups, true)) {
                    DnsMock::register(\get_class($test));
                }
            }

            if (!$test->getTestResultObject()) {
                return;
            }

            $annotations = Test::parseTestMethodAnnotations(\get_class($test)$test->getName(false));

            if (isset($annotations['class']['expectedDeprecation'])) {
                $test->getTestResultObject()->addError($testnew AssertionFailedError('"@expectedDeprecation" annotations are not allowed at the class level.'), 0);
            }
            if (isset($annotations['method']['expectedDeprecation']) || $this->checkNumAssertions = method_exists($test, 'expectDeprecation') && (new \ReflectionMethod($test, 'expectDeprecation'))->getFileName() === (new \ReflectionMethod(ExpectDeprecationTrait::class, 'expectDeprecation'))->getFileName()) {
                if (isset($annotations['method']['expectedDeprecation'])) {
                    self::$expectedDeprecations = $annotations['method']['expectedDeprecation'];
                    self::$previousErrorHandler = set_error_handler([self::class, 'handleError']);
                    @trigger_error('Since symfony/phpunit-bridge 5.1: Using "@expectedDeprecation" annotations in tests is deprecated, use the "ExpectDeprecationTrait::expectDeprecation()" method instead.', \E_USER_DEPRECATED);
                }

                


        $this->warningOnSutNotFound = $warningOnSutNotFound;
    }

    public function startTest(Test $test): void
    {
        if (!$test instanceof TestCase) {
            return;
        }

        $annotations = TestUtil::parseTestMethodAnnotations(\get_class($test)$test->getName(false));

        $ignoredAnnotations = ['covers', 'coversDefaultClass', 'coversNothing'];

        foreach ($ignoredAnnotations as $annotation) {
            if (isset($annotations['class'][$annotation]) || isset($annotations['method'][$annotation])) {
                return;
            }
        }

        $sutFqcn = ($this->sutFqcnResolver)($test);
        if (!$sutFqcn) {
            
Home | Imprint | This part of the site doesn't use cookies.