Пример #1
0
 public function testDIMultiInstance()
 {
     $key1 = 'hello';
     $value1 = 'stdClass';
     $key2 = 'Night';
     $value2 = 'stdClass';
     //register key1 in first instance, key2 in second instance
     $this->orno->add($key1, $value1);
     $orno = new OrnoContainer();
     $orno->add($key2, $value2);
     $adapter = new OrnoAdapter($orno);
     $this->container->provider($adapter);
     $this->assertInstanceOf($value1, $this->container->get($key1));
     $this->assertInstanceOf($value2, $this->container->get($key2));
 }
Пример #2
0
 /**
  * @param Container $container
  */
 public static function setupHttpClient($container)
 {
     $container->add('httpClient', function () use($container) {
         $dnsResolverFactory = new Factory();
         $loop = $container->get('eventloop');
         $dnsResolver = $dnsResolverFactory->createCached('8.8.8.8', $loop);
         $factory = new HttpFactory();
         $client = $factory->create($loop, $dnsResolver);
         return $client;
     }, true);
 }
Пример #3
0
 /**
  * @return Cache
  */
 public function getCache()
 {
     return $this->container->get('cache');
 }
Пример #4
0
 public function testCallThrowsExceptionWhenCannotResolveCallable()
 {
     $this->setExpectedException('RuntimeException');
     $c = new Container();
     $c->call('hello');
 }
Пример #5
0
 /**
  * @param Container $container
  */
 public static function setupDB(Container $container)
 {
     $container->add('db', DB::class, true)->withArgument('config');
 }