/**
  * Return Injector instance
  *
  * @param array  $modules
  * @param Cache  $cache
  * @param string $tmpDir
  *
  * @return Injector
  */
 public function newInstance(array $modules = [], Cache $cache = null, $tmpDir = null)
 {
     (new AopClassLoader())->register($tmpDir);
     $annotationReader = (new Locator())->getAnnotationReader();
     $config = $this->config ?: new Config(new Annotation(new Definition(), $annotationReader));
     $logger = $this->logger ?: new Logger();
     $tmpDir = $tmpDir ?: sys_get_temp_dir();
     $injector = new Injector(new Container(new Forge($config)), new EmptyModule(), new Bind(), new Compiler($tmpDir, new PHPParser_PrettyPrinter_Default()), $logger);
     if (count($modules) > 0) {
         $module = array_shift($modules);
         if ($cache instanceof Cache && $module instanceof ModuleCacheModule) {
             $module = $module->get($cache);
         }
         foreach ($modules as $extraModule) {
             /* @var $module AbstractModule */
             $module->install($extraModule);
         }
         $injector->setModule($module);
     }
     return $injector;
 }
 public function testApiContext()
 {
     $this->injector->setModule(new AppModule('api'));
     $actual = $this->injector->getInstance('BEAR\\Resource\\RenderInterface');
     $this->assertInstanceOf('BEAR\\Package\\Provide\\ResourceView\\HalRenderer', $actual);
 }