PHPUnit: assertInstanceOf() not working

user1173169 picture user1173169 · May 30, 2013 · Viewed 60.9k times · Source

I need to check if a variable is an object of the User type. User is my class $user my object

$this->assertInstanceOf($user,User);

This is not working, I have a use of undefined constant User - assumed 'User'

Thanks in advance for your help

Answer

Mantas picture Mantas · May 30, 2013

http://apigen.juzna.cz/doc/sebastianbergmann/phpunit/function-assertInstanceOf.html

I think you are using this function wrong. Try:

$this->assertInstanceOf('User', $user);