Skip to content

Commit

Permalink
Closes #3333
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 25, 2019
1 parent ccc28ad commit b083649
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 297 deletions.
32 changes: 0 additions & 32 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,6 @@ public function runBare(): void
}
}

$this->setExpectedExceptionFromAnnotation();
$this->setDoesNotPerformAssertionsFromAnnotation();

foreach ($hookMethods['before'] as $method) {
Expand Down Expand Up @@ -1903,37 +1902,6 @@ protected function onNotSuccessfulTest(\Throwable $t): void
throw $t;
}

private function setExpectedExceptionFromAnnotation(): void
{
if ($this->name === null) {
return;
}

try {
$expectedException = TestUtil::getExpectedException(
\get_class($this),
$this->name
);

if ($expectedException !== false) {
$this->addWarning('The @expectedException, @expectedExceptionCode, @expectedExceptionMessage, and @expectedExceptionMessageRegExp annotations are deprecated. They will be removed in PHPUnit 9. Refactor your test to use expectException(), expectExceptionCode(), expectExceptionMessage(), or expectExceptionMessageRegExp() instead.');

$this->expectException($expectedException['class']);

if ($expectedException['code'] !== null) {
$this->expectExceptionCode($expectedException['code']);
}

if ($expectedException['message'] !== '') {
$this->expectExceptionMessage($expectedException['message']);
} elseif ($expectedException['message_regex'] !== '') {
$this->expectExceptionMessageRegExp($expectedException['message_regex']);
}
}
} catch (UtilException $e) {
}
}

/**
* @throws Warning
* @throws SkippedTestError
Expand Down
57 changes: 0 additions & 57 deletions src/Util/Annotation/DocBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ final class DocBlock

private const REGEX_TEST_WITH = '/@testWith\s+/';

private const REGEX_EXPECTED_EXCEPTION = '(@expectedException\s+([:.\w\\\\x7f-\xff]+)(?:[\t ]+(\S*))?(?:[\t ]+(\S*))?\s*$)m';

/** @var string */
private $docComment;

Expand Down Expand Up @@ -238,61 +236,6 @@ public function requirements(): array
);
}

/**
* @return array|bool
*
* @psalm-return false|array{
* class: class-string,
* code: int|string|null,
* message: string,
* message_regex: string
* }
*/
public function expectedException()
{
$docComment = (string) \substr($this->docComment, 3, -2);

if (1 !== \preg_match(self::REGEX_EXPECTED_EXCEPTION, $docComment, $matches)) {
return false;
}

/** @psalm-var class-string $class */
$class = $matches[1];
$annotations = $this->symbolAnnotations();
$code = null;
$message = '';
$messageRegExp = '';

if (isset($matches[2])) {
$message = \trim($matches[2]);
} elseif (isset($annotations['expectedExceptionMessage'])) {
$message = $this->parseAnnotationContent($annotations['expectedExceptionMessage'][0]);
}

if (isset($annotations['expectedExceptionMessageRegExp'])) {
$messageRegExp = $this->parseAnnotationContent($annotations['expectedExceptionMessageRegExp'][0]);
}

if (isset($matches[3])) {
$code = $matches[3];
} elseif (isset($annotations['expectedExceptionCode'])) {
$code = $this->parseAnnotationContent($annotations['expectedExceptionCode'][0]);
}

if (\is_numeric($code)) {
$code = (int) $code;
} elseif (\is_string($code) && \defined($code)) {
$code = (int) \constant($code);
}

return [
'class' => $class,
'code' => $code,
'message' => $message,
'message_regex' => $messageRegExp,
];
}

/**
* Returns the provided data for a method.
*
Expand Down
14 changes: 0 additions & 14 deletions src/Util/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,20 +279,6 @@ public static function getMissingRequirements(string $className, string $methodN
return $missing;
}

/**
* Returns the expected exception for a test.
*
* @return array|false
*
* @deprecated
* @codeCoverageIgnore
* @psalm-param class-string $className
*/
public static function getExpectedException(string $className, string $methodName)
{
return Registry::getInstance()->forMethod($className, $methodName)->expectedException();
}

/**
* Returns the provided data for a method.
*
Expand Down
45 changes: 0 additions & 45 deletions tests/_files/ExceptionNamespaceTest.php

This file was deleted.

149 changes: 0 additions & 149 deletions tests/_files/ExceptionTest.php

This file was deleted.

0 comments on commit b083649

Please sign in to comment.