Skip to content

Commit 1474ebb

Browse files
committed
Improved error message
1 parent 50b5432 commit 1474ebb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Symfony/Cmf/Component/Testing/Unit/Constraint/SchemaAcceptsXml.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,22 @@ public function toString() { }
4747
protected function failureDescription($schemaFile)
4848
{
4949
return sprintf(
50-
'"%s" is accepted by the XML schema "%s"',
51-
\PHPUnit_Util_Type::export($this->xml[$this->failingElement]),
50+
"Xml is accepted by the XML schema \"%s\"",
5251
$schemaFile
5352
);
5453
}
5554

5655
protected function additionalFailureDescription($schema)
5756
{
58-
$str = '';
57+
$str = "\n".$this->xml[$this->failingElement]->saveXml()."\n\n";
5958

6059
foreach ($this->errors as $error) {
61-
$str .= $error->message.($error->file ? ' in'.$error->file : '').' on line '.$error->line."\n";
60+
$error = trim($error->message).($error->file ? ' in'.$error->file : '').' on line '.$error->line."\n";
61+
62+
// avoid repeating same error
63+
if (false === strpos($str, $error)) {
64+
$str .= $error;
65+
}
6266
}
6367

6468
return $str;

0 commit comments

Comments
 (0)