Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

#master: add JSON content into validation errors exception message #274

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "behatch/contexts",
"name": "astinus/contexts",
"description": "Behatch contexts",
"keywords": ["BDD", "Behat", "Symfony2", "Context"],
"type": "library",
Expand Down Expand Up @@ -34,6 +34,7 @@
},

"replace": {
"behatch/contexts": "self.version",
"sanpi/behatch-contexts": "self.version"
},

Expand Down
1 change: 1 addition & 0 deletions src/Json/JsonSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function validate(Json $json, Validator $validator)
foreach ($validator->getErrors() as $error) {
$msg .= sprintf(" - [%s] %s".PHP_EOL, $error['property'], $error['message']);
}
$msg .= "JSON is:".PHP_EOL.$json->encode().PHP_EOL;
throw new \Exception($msg);
}

Expand Down
6 changes: 6 additions & 0 deletions tests/units/Json/JsonSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public function test_validate_invalid()
->hasMessage(<<<EOD
JSON does not validate. Violations:
- [] The property foo is not defined and the definition does not allow additional properties
JSON is:
{
"foo": {
"bar": "foobar"
}
}

EOD
);
Expand Down