<?php
/**
* Test: NetteDIContainer static usage.
*
* @author David Grudl
* @package NetteDI
* @subpackage UnitTests
*/
use NetteDIContainer;
require __DIR__ . '/../bootstrap.php';
class MyContainer extends Container
{
protected function createServiceOne()
{
return new stdClass;
}
protected function createServiceTwo()
{
}
}
$container = new MyContainer;
assert::
true( $container->
hasService('one') );
assert::
false( $container->
hasService('undefined') );
assert::
true( $container->
getService('one') instanceof stdClass
);
assert::
same( $container->
getService('one'),
$container->
getService('one') );
// shared
// bad method
assert::
throws(function() use
($container) {
$container->getService('two');
}, 'NetteUnexpectedValueException', "Unable to create service 'two', value returned by factory 'createServiceTwo' is not object.");