2011-10-06 10 views

risposta

16

Utilizzare assertInstanceOf() anziché l'operatore o le funzioni integrate di PHP instanceof in modo da ottenere un messaggio di errore significativo.

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

... 

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

O anche si dovrebbe utilizzare questa asserzione come questo:

$this->assertSame(
     'Symfony\Component\Form\AbstractType', 
     get_parent_class('AppBundle\Form\CarType'), 
     'The form does not extend the AbstractType class' 
     ); 
Problemi correlati