Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 1 addition & 37 deletions PhpUnit/ConfigurationValuesAreInvalidConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

namespace Matthias\SymfonyConfigTest\PhpUnit;

use PHPUnit\Framework\Constraint\ExceptionMessage;
use PHPUnit\Framework\Constraint\ExceptionMessageIsOrContains;
use PHPUnit\Framework\Constraint\ExceptionMessageMatchesRegularExpression;
use PHPUnit\Framework\Constraint\ExceptionMessageRegularExpression;
use PHPUnit\Framework\Constraint\MessageIsOrContains;
use PHPUnit\Framework\Constraint\MessageMatchesRegularExpression;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;

Expand Down Expand Up @@ -64,38 +59,7 @@ private function evaluateException(\Exception $exception, $description, $returnR
return true;
}

return $this->createPhpUnitConstraint()
return (new ExceptionMessageMatchesRegularExpression($this->expectedMessage))
->evaluate($exception, $description, $returnResult);
}

private function createPhpUnitConstraint()
{
if ($this->useRegExp) {
// Available since PHPUnit 10.0.15
if (class_exists(ExceptionMessageMatchesRegularExpression::class)) {
return new ExceptionMessageMatchesRegularExpression($this->expectedMessage);
}

// Available between PHPUnit 10.0.0 and 10.0.14 (inclusive)
if (class_exists(MessageMatchesRegularExpression::class)) {
return new MessageMatchesRegularExpression('exception', $this->expectedMessage);
}

// Available in PHPUnit 9.6
return new ExceptionMessageRegularExpression($this->expectedMessage);
}

// Available since PHPUnit 10.0.15
if (class_exists(ExceptionMessageIsOrContains::class)) {
return new ExceptionMessageIsOrContains($this->expectedMessage);
}

// Available between PHPUnit 10.0.0 and 10.0.14 (inclusive)
if (class_exists(MessageIsOrContains::class)) {
return new MessageIsOrContains('exception', $this->expectedMessage);
}

// Available in PHPUnit 9.6
return new ExceptionMessage($this->expectedMessage);
}
}
Loading