You can also use a docblock annotation until PHPUnit 9 is released:
class ExceptionTest extends PHPUnit_Framework_TestCase
{
/**
* @expectedException InvalidArgumentException
*/
public function testException()
{
...
}
}
For PHP 5.5+ (especially with namespaced code), I now prefer using ::class