Skip to content

Commit

Permalink
Adding a test for recursive parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
moufmouf committed Nov 29, 2015
1 parent 7f43e2a commit 1bc059b
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions src/AbstractDefinitionCompatibilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class AbstractDefinitionCompatibilityTest extends \PHPUnit_Framework_Te
*/
abstract protected function getContainer(DefinitionProviderInterface $definitionProvider);

public function testInstanceConverter()
public function testInstance()
{
$referenceDefinition = new \Assembly\ObjectDefinition('foo', '\\stdClass');

Expand Down Expand Up @@ -59,7 +59,7 @@ public function testParameterException()
/**
* Test method calls and property assignments
*/
public function testInstanceConverterPropertiesAndMethodCalls()
public function testInstancePropertiesAndMethodCalls()
{
$assemblyDefinition = new \Assembly\ObjectDefinition('bar', 'Interop\Container\Definition\Test\Fixtures\\Test');
$assemblyDefinition->addMethodCall('setArg1', 42);
Expand All @@ -75,7 +75,7 @@ public function testInstanceConverterPropertiesAndMethodCalls()
$this->assertEquals(43, $result->cArg2);
}

public function testParameterConverter()
public function testParameter()
{
$assemblyDefinition = new \Assembly\ParameterDefinition('foo', '42');

Expand All @@ -87,7 +87,7 @@ public function testParameterConverter()
$this->assertEquals(42, $result);
}

public function testAliasConverter()
public function testAlias()
{
$aliasDefinition = new \Assembly\AliasDefinition('foo', 'bar');

Expand All @@ -103,7 +103,7 @@ public function testAliasConverter()
$this->assertTrue($result === $result2);
}

public function testFactoryConverter()
public function testFactory()
{
$factoryAssemblyDefinition = new \Assembly\ObjectDefinition('factory', 'Interop\Container\Definition\Test\Fixtures\\TestFactory');
$factoryAssemblyDefinition->addConstructorArgument(42);
Expand All @@ -123,7 +123,7 @@ public function testFactoryConverter()
/**
* @expectedException \RuntimeException
*/
public function testUnsupportedDefinitionConverter()
public function testUnsupportedDefinition()
{
$definition = new UnsupportedDefinition();

Expand All @@ -132,4 +132,30 @@ public function testUnsupportedDefinitionConverter()
]));
$container->get('foo');
}

public function testRecursiveArrayParameters()
{
$referenceDefinition = new \Assembly\ObjectDefinition('foo', '\\stdClass');

$assemblyDefinition = new \Assembly\ObjectDefinition('bar', 'Interop\Container\Definition\Test\Fixtures\\Test');
$assemblyDefinition->addConstructorArgument(42);
$assemblyDefinition->addConstructorArgument([
'recursive' => [
'hello' => 'world',
'foo' => new Reference('foo'),
]
]);

$container = $this->getContainer(new ArrayDefinitionProvider([
'bar' => $assemblyDefinition,
'foo' => $referenceDefinition,
]));
$result = $container->get('bar');

$this->assertInstanceOf('Interop\Container\Definition\Test\Fixtures\\Test', $result);
$this->assertEquals(42, $result->cArg1);
$this->assertEquals('world', $result->cArg2['recursive']['hello']);
$this->assertInstanceOf('stdClass', $result->cArg2['recursive']['foo']);
}

}

0 comments on commit 1bc059b

Please sign in to comment.