Skip to content

Commit

Permalink
Fix message in UnexpectedRuleException (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Dec 8, 2022
1 parent 68be67a commit 5db30c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/Exception/UnexpectedRuleException.php
Expand Up @@ -44,9 +44,12 @@ public function __construct(
*/
object $actualObject
) {
$actualClassName = $actualObject::class;
$message = "Expected \"$expectedClassName\", but {$actualClassName} given.";

parent::__construct($message);
parent::__construct(
sprintf(
'Expected "%s", but "%s" given.',
$expectedClassName,
$actualObject::class
)
);
}
}
2 changes: 1 addition & 1 deletion tests/Rule/Base/DifferentRuleInHandlerTestTrait.php
Expand Up @@ -19,7 +19,7 @@ public function testDifferentRuleInHandler(): void

$this->expectException(UnexpectedRuleException::class);
$this->expectExceptionMessage(
'Expected "' . $ruleClassName . '", but ' . RuleWithCustomHandler::class . ' given.'
'Expected "' . $ruleClassName . '", but "' . RuleWithCustomHandler::class . '" given.'
);
$validator->validate([], [$rule]);
}
Expand Down

0 comments on commit 5db30c0

Please sign in to comment.