<?php
/**
* Test: NetteDIContainer cloning.
*
* @author David Grudl
* @package NetteDI
* @subpackage UnitTests
*/
use NetteDIContainer;
require __DIR__ . '/../bootstrap.php';
class Service
{
}
$service = new Service;
$container = new Container;
$container->addService('one', $service);
$container->addService('two', 'Service');
$container->addService('three', function($container){
return new Service;
});
$dolly = clone $container;
assert::
same( $dolly->
getService('one'),
$container->
getService('one') );
assert::
same( $dolly->
getService('two'),
$container->
getService('two') );
assert::
same( $dolly->
getService('three'),
$container->
getService('three') );
$container->addService('oneX', $service);
$container->addService('twoX', 'Service');
$container->addService('threeX', function($container){
return new Service;
});
assert::
false( $dolly->
hasService('oneX') );
assert::
false( $dolly->
hasService('twoX') );
assert::
false( $dolly->
hasService('threeX') );