Skip to content

Commit a8c5ade

Browse files
Merge pull request #25 from Soullivaneuh/patch-1
Show configuration error on invalid
2 parents f8fa058 + 0f77545 commit a8c5ade

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

PhpUnit/ConfigurationValuesAreValidConstraint.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function __construct(ConfigurationInterface $configuration, $breadcrumbPa
1212
parent::__construct($configuration, $breadcrumbPath);
1313
}
1414

15-
public function matches($other)
15+
public function evaluate($other, $description = '', $returnResult = false)
1616
{
1717
$this->validateConfigurationValuesArray($other);
1818

@@ -22,9 +22,16 @@ public function matches($other)
2222
$this->processConfiguration($other);
2323
} catch (InvalidConfigurationException $exception) {
2424
$success = false;
25+
$description = empty($description) ? $exception->getMessage() : $description."\n".$exception->getMessage();
2526
}
2627

27-
return $success;
28+
if ($returnResult) {
29+
return $success;
30+
}
31+
32+
if (!$success) {
33+
$this->fail($other, $description);
34+
}
2835
}
2936

3037
public function toString()

Tests/PhpUnit/AbstractConfigurationTestCaseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function it_can_assert_that_a_configuration_is_valid()
5959
*/
6060
public function it_fails_when_a_configuration_is_invalid_when_it_should_have_been_valid()
6161
{
62-
$this->setExpectedException('\PHPUnit_Framework_ExpectationFailedException', 'valid');
62+
$this->setExpectedException('\PHPUnit_Framework_ExpectationFailedException', 'The child node "required_value" at path "root" must be configured.');
6363

6464
$this->assertConfigurationIsValid(
6565
array(

Tests/PhpUnit/ConfigurationTestCaseTraitActual.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function it_can_assert_that_a_configuration_is_valid()
5858
*/
5959
public function it_fails_when_a_configuration_is_invalid_when_it_should_have_been_valid()
6060
{
61-
$this->setExpectedException('\PHPUnit_Framework_ExpectationFailedException', 'valid');
61+
$this->setExpectedException('\PHPUnit_Framework_ExpectationFailedException', 'The child node "required_value" at path "root" must be configured.');
6262

6363
$this->assertConfigurationIsValid(
6464
array(

0 commit comments

Comments
 (0)