2011-10-06 32 views

Trả lời

16

Sử dụng assertInstanceOf() thay vì PHP được xây dựng trong instanceof toán tử hoặc chức năng để bạn nhận được thông báo lỗi có ý nghĩa.

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

... 

Failed asserting that <Foo> is an instance of class "Bar". 
0

Hoặc cũng có thể bạn nên sử dụng khẳng định này như sau:

$this->assertSame(
     'Symfony\Component\Form\AbstractType', 
     get_parent_class('AppBundle\Form\CarType'), 
     'The form does not extend the AbstractType class' 
     ); 
Các vấn đề liên quan