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)); }
/** * @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); }
/** * @return Cache */ public function getCache() { return $this->container->get('cache'); }
public function testCallThrowsExceptionWhenCannotResolveCallable() { $this->setExpectedException('RuntimeException'); $c = new Container(); $c->call('hello'); }
/** * @param Container $container */ public static function setupDB(Container $container) { $container->add('db', DB::class, true)->withArgument('config'); }