I am working on cakephp. I want to know how can I test if something is not saving into db. I mean I want to do a unit testing and I want to echo the result just for checking purposes and to know whether I am writing a correct exception handling code or not. here is my code which I am trying
try {
if (! $this->User->save($data))
throw new Exception('Error saving data');
} catch (Exception $e) {
echo "data is not saving into the db";
die();
}
echo "data saves successfully";
is this the right code above.and what result will printed out on the screen if data doesn't successfully save into DB. THIS one "Error saving data" or this one "data is not saving into the db"