PHPUnit:如何断言一个类扩展另一个类?

And*_*rew 15 php phpunit

在我的PHPUnit测试中,我想声明我正在测试的类扩展了另一个类.我怎么能用PHPUnit做到这一点?

Dav*_*ess 18

使用assertInstanceOf()而不是PHP的内置instanceof运算符或函数,以便您获得有意义的失败消息.

function testInstanceOf() {
    $obj = new Foo;
    self::assertInstanceOf('Bar', $obj);
}

...

Failed asserting that <Foo> is an instance of class "Bar".
Run Code Online (Sandbox Code Playgroud)