Skip to content

Commit

Permalink
Add more test-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryPEGEOT committed Apr 3, 2018
1 parent 2612f81 commit 15c45ee
Showing 1 changed file with 19 additions and 7 deletions.
Expand Up @@ -205,17 +205,29 @@ public function testBadInterfaceForAutomaticInstanceofIsOk()
public function testProcessForAutoconfiguredCalls()
{
$container = new ContainerBuilder();
$container->registerForAutoconfiguration(parent::class)->addMethodCall('setLogger');

$def = $container->register('foo', self::class)->setAutoconfigured(true);
$this->assertFalse($def->hasMethodCall('setLogger'), 'Definition shouldn\'t have method call yet.');
$expected = array(
array('setFoo', array(
'plain_value',
'%some_parameter%'
)),
array('callBar', array()),
array('isBaz', array()),
);

(new ResolveInstanceofConditionalsPass())->process($container);
$container->registerForAutoconfiguration(parent::class)->addMethodCall('setFoo', $expected[0][1]);
$container->registerForAutoconfiguration(self::class)->addMethodCall('callBar');

$this->assertTrue(
$container->findDefinition('foo')->hasMethodCall('setLogger'),
'Definition should have "setLogger" method call.'
$def = $container->register('foo', self::class)->setAutoconfigured(true)->addMethodCall('isBaz');
$this->assertEquals(
array(array('isBaz', array())),
$def->getMethodCalls(),
'Definition shouldn\'t have only one method call.'
);

(new ResolveInstanceofConditionalsPass())->process($container);

$this->assertEquals($expected, $container->findDefinition('foo')->getMethodCalls());
}

/**
Expand Down

0 comments on commit 15c45ee

Please sign in to comment.