Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion PhpUnit/ConfigurationValuesAreInvalidConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private function evaluateException(\Exception $exception, $description, $returnR
}

return $this->createPhpUnitConstraint()
->evaluate($exception, $description, $returnResult);
->evaluate($exception->getMessage(), $description, $returnResult);
}

private function createPhpUnitConstraint()
Expand Down
20 changes: 20 additions & 0 deletions Tests/PhpUnit/ConfigurationValuesAreInvalidConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Matthias\SymfonyConfigTest\Tests\PhpUnit\Fixtures\AlwaysValidConfiguration;
use Matthias\SymfonyConfigTest\Tests\PhpUnit\Fixtures\ConfigurationWithRequiredValue;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestCase;

class ConfigurationValuesAreInvalidConstraintTest extends TestCase
Expand Down Expand Up @@ -82,6 +83,25 @@ public function if_configuration_values_are_invalid_it_matches_when_exception_me
$this->assertTrue($constraint->evaluate([[]], '', true));
}

#[Test]
public function the_failure_message_contains_the_actual_exception_message()
{
$constraint = new ConfigurationValuesAreInvalidConstraint(
new ConfigurationWithRequiredValue(),
'expected message which will not be part of the actual message'
);

try {
$constraint->evaluate([[]]);
} catch (ExpectationFailedException $exception) {
$this->assertStringContainsString('required_value', $exception->getMessage());

return;
}

$this->fail('Expected an ExpectationFailedException to be thrown');
}

#[Test]
public function to_string_returns_a_message()
{
Expand Down
Loading