I have a class that gives a non-fatal notification:
class MyClass {
public function foo(){
trigger_error('Notice this message.', E_USER_NOTICE);
return true;
}
}
Here's the basic unit test:
class MyClassTest extends PHPUnit_Framework_TestCase {
public function testCanFoo(){
$obj = new MyClass;
$this->assertTrue($obj->foo());
}
}
Naturally, PHPUnit converts this notification into an exception, which does not necessarily throw a test as an error.
1 error occurred:
1) MyClassTest :: testCanFoo
Pay attention to this post.
First, let me point out that I like that I can read this notice, and this one is what I want , but without verification.
I know that I can pass the test with docblock .
class MyClassTest extends PHPUnit_Framework_TestCase {
public function testCanFoo(){
$obj = new MyClass;
$this->assertTrue($obj->foo());
}
}
But now the notification is completely absorbed.
PHPUnit 5.5.4 by Sebastian Bergman and contributors.
. 1/1 (100%)
Time: 17 ms, memory: 4.00 MB
OK (1 test, 1 statement)
?