Skip to content
Permalink
Browse files

Improving the exception messages for the FixtureManager.

Before the message was very generic and not telling you which fixture caused the failure.
  • Loading branch information...
burzum committed Feb 3, 2016
1 parent 6a36f60 commit 8921661a06556a1abc6ab2961fb4d3b5b43548b9
Showing with 19 additions and 4 deletions.
  1. +19 −4 src/TestSuite/Fixture/FixtureManager.php
@@ -274,7 +274,12 @@ public function load($test)
foreach ($fixtures as $name => $fixture) {
if (in_array($fixture->table, $tables)) {
$fixture->dropConstraints($db);
try {
$fixture->dropConstraints($db);
} catch (PDOException $e) {
$msg = sprintf('Unable to drop constraints for fixture "%s" for "%s" test case: ' . "\n" . '%s', get_class($fixture), get_class($test), $e->getMessage());
throw new Exception($msg);
}
}
}
@@ -287,15 +292,25 @@ public function load($test)
}
foreach ($fixtures as $name => $fixture) {
$fixture->createConstraints($db);
try {
$fixture->createConstraints($db);
} catch (PDOException $e) {
$msg = sprintf('Unable to create constriants for fixture "%s" for "%s" test case: ' . "\n" . '%s', get_class($fixture), get_class($test), $e->getMessage());
throw new Exception($msg);
}
}
};
$this->_runOperation($fixtures, $createTables);
// Use a separate transaction because of postgres.
$insert = function ($db, $fixtures) {
$insert = function ($db, $fixtures) use ($test) {
foreach ($fixtures as $fixture) {
$fixture->insert($db);
try {
$fixture->insert($db);
} catch (PDOException $e) {
$msg = sprintf('Unable to insert fixture "%s" for "%s" test case: ' . "\n" . '%s', get_class($fixture), get_class($test), $e->getMessage());
throw new Exception($msg);
}
}
};
$this->_runOperation($fixtures, $insert);

0 comments on commit 8921661

Please sign in to comment.
You can’t perform that action at this time.