/** * {@inheritdoc} * @see Scalr\Tests.TestCase::setUp() */ protected function setUp() { $this->container = \Scalr::getContainer(); //Usual service $this->container->test1 = function ($cont) { return new DiObject1(); }; //Shared service $this->container->setShared('test2', function ($cont) { return new DiObject1(); }); //Service which is using singletone behaviour //but delegated internally by additional parameters. $this->container->test3 = function ($cont, $args) { $params = array(); $params['region'] = isset($args[0]) ? $args[0] : 'default'; $serviceid = 'test3.' . md5($params['region']); if (!$cont->initialized($serviceid)) { $cont->setShared($serviceid, function ($cont) use($params) { return new DiObject1($params['region']); }); } return $cont->get($serviceid); }; }