PHPUnit:如何断言一个类扩展了另一个类?
在PHPUnit测试中,我想断言我正在测试的类扩展了另一个类。如何使用PHPUnit实现这一点?如何使用instanceof ->(或可能)可能是您正在寻找的对象。使用PHP内置的PHPUnit:如何断言一个类扩展了另一个类?,php,phpunit,Php,Phpunit,在PHPUnit测试中,我想断言我正在测试的类扩展了另一个类。如何使用PHPUnit实现这一点?如何使用instanceof ->(或可能)可能是您正在寻找的对象。使用PHP内置的instanceof运算符或函数,以获得有意义的失败消息 function testInstanceOf() { $obj = new Foo; self::assertInstanceOf('Bar', $obj); } ... Failed asserting that <Foo>
instanceof
运算符或函数,以获得有意义的失败消息
function testInstanceOf() {
$obj = new Foo;
self::assertInstanceOf('Bar', $obj);
}
...
Failed asserting that <Foo> is an instance of class "Bar".
function testInstanceOf(){
$obj=新的Foo;
self::断言('Bar',$obj);
}
...
断言类“Bar”的实例失败。
或者您也应该像这样使用此断言:
$this->assertSame(
'Symfony\Component\Form\AbstractType',
get_parent_class('AppBundle\Form\CarType'),
'The form does not extend the AbstractType class'
);