Hi, my question regarding phpunit for testing exceptions using the command line tool. I can't seem to correctly do this, the error message of the exception just prints out, making the command line window harder to read. Below is how my code is structured and the test code.
public function availableFruits($fruit)
{
switch($fruit) {
case 'foo':
// all good
break;
case 'bar':
// all good
break;
default:
throw new Exception($fruit.' not available!');
break;
}
}
public function chooseFruit($fruit)
{
try {
availableFruits($fruit);
} catch (Exception $e) {
echo $e->getMessage();
}
}
public function testAvailableFruits()
{
$this->setExpectedException('Exception');
chooseFruit('Kiwi');
}
The error message will print out in the command line window like below. I tried all the methods shown in phpunit.de but same results.
..Error on line 13 in c:\file\path\fruits.php: Kiwi not available!.F
The error line prints out, how do I suppress that, am I doing it right at all?
Thanks!