Nelmio\Alice\Throwable\Exception\Generator\Instantiator\InstantiationExceptionFactory::createForInvalidInstanceType PHP Method

createForInvalidInstanceType() public static method

public static createForInvalidInstanceType ( Nelmio\Alice\FixtureInterface $fixture, object $instance ) : InstantiationException
$fixture Nelmio\Alice\FixtureInterface
$instance object
return InstantiationException
    public static function createForInvalidInstanceType(FixtureInterface $fixture, $instance) : InstantiationException
    {
        return new InstantiationException(sprintf('Instantiated fixture was expected to be an instance of "%s". Got "%s" instead.', $fixture->getClassName(), get_class($instance)));
    }

Usage Example

 public function testTestCreateForInvalidInstanceType()
 {
     $exception = InstantiationExceptionFactory::createForInvalidInstanceType(new SimpleFixture('foo', 'Dummy', SpecificationBagFactory::create()), new \stdClass());
     $this->assertEquals('Instantiated fixture was expected to be an instance of "Dummy". Got "stdClass" instead.', $exception->getMessage());
     $this->assertEquals(0, $exception->getCode());
     $this->assertNull($exception->getPrevious());
 }
All Usage Examples Of Nelmio\Alice\Throwable\Exception\Generator\Instantiator\InstantiationExceptionFactory::createForInvalidInstanceType