$this->
assertEquals('sc_configure',
$services['configurator1'
]->
getConfigurator(), '->load() parses the configurator tag'
);
$this->
assertEquals([new Reference('baz'
), 'configure'
],
$services['configurator2'
]->
getConfigurator(), '->load() parses the configurator tag'
);
$this->
assertEquals(['BazClass', 'configureStatic'
],
$services['configurator3'
]->
getConfigurator(), '->load() parses the configurator tag'
);
$this->
assertEquals([['setBar',
[]],
['setBar',
[new Expression('service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")'
)]]],
$services['method_call1'
]->
getMethodCalls(), '->load() parses the method_call tag'
);
$this->
assertEquals([['setBar',
['foo',
new Reference('foo'
),
[true, false
]]]],
$services['method_call2'
]->
getMethodCalls(), '->load() parses the method_call tag'
);
$this->
assertEquals('factory',
$services['new_factory1'
]->
getFactory(), '->load() parses the factory tag'
);
$this->
assertEquals([new Reference('baz'
), 'getClass'
],
$services['new_factory2'
]->
getFactory(), '->load() parses the factory tag'
);
$this->
assertEquals(['BazClass', 'getInstance'
],
$services['new_factory3'
]->
getFactory(), '->load() parses the factory tag'
);
$this->
assertSame([null, 'getInstance'
],
$services['new_factory4'
]->
getFactory(), '->load() accepts factory tag without class'
);
$this->
assertEquals([new Reference('baz'
), '__invoke'
],
$services['new_factory5'
]->
getFactory(), '->load() accepts service reference as invokable factory'
);
$aliases =
$container->
getAliases();
$this->
assertArrayHasKey('alias_for_foo',
$aliases, '->load() parses <service> elements'
);
$this->
assertEquals('foo',
(string) $aliases['alias_for_foo'
], '->load() parses aliases'
);
$this->
assertFalse($aliases['alias_for_foo'
]->
isPublic());
$this->
assertArrayHasKey('another_alias_for_foo',
$aliases);
$this->
assertEquals('foo',
(string) $aliases['another_alias_for_foo'
]);
$this->
assertTrue($aliases['another_alias_for_foo'
]->
isPublic());
$this->
assertEquals(['decorated', null, 0
],
$services['decorator_service'
]->
getDecoratedService());
$this->
assertEquals(['decorated', 'decorated.pif-pouf', 0
],
$services['decorator_service_with_name'
]->
getDecoratedService());
$this->
assertEquals(['decorated', 'decorated.pif-pouf', 5
],
$services['decorator_service_with_name_and_priority'
]->
getDecoratedService());
$this->
assertEquals(['decorated', 'decorated.pif-pouf', 5, ContainerInterface::IGNORE_ON_INVALID_REFERENCE
],
$services['decorator_service_with_name_and_priority_and_on_invalid'
]->
getDecoratedService());
}