Skip to content

Commit

Permalink
Fix error on static factory with associative array
Browse files Browse the repository at this point in the history
  • Loading branch information
ogizanagi committed Apr 14, 2017
1 parent 056f173 commit ce9b06f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function createInstance(FixtureInterface $fixture)
$arguments = [];
}

$instance = $factory::$method(...$arguments);
$instance = $factory::$method(...array_values($arguments));
if (false === $instance instanceof $class) {
throw InstantiationExceptionFactory::createForInvalidInstanceType($fixture, $instance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,27 @@ public function testInstantiatesObjectWithFactoryAndArguments()
$this->assertEquals($expected, $actual);
}

public function testInstantiatesObjectWithFactoryAndNamedArguments()
{
$fixture = new SimpleFixture(
'dummy',
DummyWithNamedConstructorAndOptionalParameters::class,
SpecificationBagFactory::create(
new MethodCallWithReference(
new StaticReference(DummyWithNamedConstructorAndOptionalParameters::class),
'namedConstruct',
['param' => 10]
)
)
);
$set = $this->instantiator->instantiate($fixture, ResolvedFixtureSetFactory::create(), new GenerationContext());

$expected = DummyWithNamedConstructorAndOptionalParameters::namedConstruct(10);
$actual = $set->getObjects()->get($fixture)->getInstance();

$this->assertEquals($expected, $actual);
}

/**
* @expectedException \Nelmio\Alice\Throwable\Exception\Generator\Instantiator\InstantiationException
* @expectedExceptionMessage Could not instantiate fixture "dummy".
Expand Down

0 comments on commit ce9b06f

Please sign in to comment.