本文整理汇总了PHP中Joomla\DI\Container::createChild方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::createChild方法的具体用法?PHP Container::createChild怎么用?PHP Container::createChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joomla\DI\Container
的用法示例。
在下文中一共展示了Container::createChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testChildResolveAlias
/**
* @testdox Child container resolves parent's alias to parent's resource
*/
public function testChildResolveAlias()
{
$container = new Container();
$container->set('Joomla\\Tests\\Unit\\DI\\StubInterface', function () {
return new Stub1();
});
$container->alias('stub', 'Joomla\\Tests\\Unit\\DI\\StubInterface');
$child = $container->createChild();
$this->assertInstanceOf('Joomla\\Tests\\Unit\\DI\\Stub1', $child->get('stub'));
}
示例2: testCreateChild
/**
* Tests the creation of a child Container.
*
* @return void
*/
public function testCreateChild()
{
$child = $this->fixture->createChild();
$this->assertAttributeInstanceOf('Joomla\\DI\\Container', 'parent', $child, 'When creating a child container, the $parent property should be an instance of Joomla\\DI\\Container.');
$this->assertAttributeSame($this->fixture, 'parent', $child, 'When creating a child container, the $parent property should be the same as the creating Container.');
}