Why PHPUnit test doesn't fail?

Posted by JohnM2 on Stack Overflow See other posts from Stack Overflow or by JohnM2
Published on 2011-01-06T11:54:27Z Indexed on 2011/01/07 10:53 UTC
Read the original article Hit count: 287

Filed under:

I have a test method which looks like that:

$row = $this->GetRowFromUserTable($id);
$this->asserLessThan(time(), time($row['last_update']));

When $row is null access to $row['last_update'] should trigger a NOTICE and this test should fail, but it doesn't.

This code fails on first assert, so I know $db_row is null (fixture is the same):

$row = $this->GetRowFromUserTable($id);
$this->asserNotNull($row);
$this->asserLessThan(time(), time($row['last_update']));

When I write this:

$row = $this->GetRowFromUserTable($id);
$this->assertEquals(E_ALL, error_reporting());
$this->asserLessThan(time(), time($row['last_update']));

it successes, so I am also sure that error_reproting is right and this situation must have something to do with PHPUnit.

I use PHPUnit 3.5.6

I read this question: Can I make PHPUnit fail if the code throws a notice? but the answer suggests to use newer version of PHPUnit, but that answer is from 2009, so it's not it.

EDIT: I use NetBeans IDE 6.9.1 to run my test.

© Stack Overflow or respective owner

Related posts about phpunit