示例#1
0
 protected function setUp()
 {
     parent::setUp();
     $injector = Injector::create([new TestModule()], false);
     $app = $injector->getInstance('BEAR\\Sunday\\Application\\Context');
     $this->resource = $app->resource;
 }
示例#2
0
 protected function setUp()
 {
     static $app;
     parent::setUp();
     if (!$app) {
         $injector = Injector::create([new AppModule()]);
         $app = $injector->getInstance('BEAR\\Sunday\\Application\\Context');
     }
     $this->resource = $app->resource;
 }
 protected function setUp()
 {
     static $module;
     static $injector;
     if (!$module) {
         $module = new AppModule('prod');
         $module->activate();
     }
     if (!$injector) {
         $injector = Injector::create([$module]);
     }
     $this->module = clone $module;
     $this->injector = clone $injector;
     parent::setUp();
 }
示例#4
0
<?php

/**
 * Sandbox
 *
 * @package App.Sandbox
 */
use Helloworld\Module\AppModule;
use Ray\Di\Injector;
require_once __DIR__ . '/load.php';
$app = apc_fetch('app-helloworld');
if ($app) {
    return $app;
}
$injector = Injector::create([new AppModule()]);
$app = $injector->getInstance('BEAR\\Sunday\\Application\\Context');
apc_store('app-helloworld', $app);
return $app;
示例#5
0
 /**
  * @param $apps
  * @param $context
  * @param $tmpDir
  *
  * @return \BEAR\Sunday\Extension\Application\AppInterface
  */
 public static function getApp($apps, $context, $tmpDir)
 {
     $injector = Injector::create([new AppModule($context, $apps)]);
     $app = $injector->getInstance('BEAR\\Sunday\\Extension\\Application\\AppInterface');
     return $app;
 }
<?php

use BEAR\Package\Dev\Dev;
use Ray\Di\Injector;
use My\Hello\Module\AppModule;
error_reporting(E_ALL);
ini_set('xdebug.max_nesting_level', 300);
// load
$loader = (require dirname(__DIR__) . '/vendor/autoload.php');
/** @var $loader \Composer\Autoload\ClassLoader */
$loader->addPsr4('My\\Hello\\', __DIR__);
// set the application path into the globals so we can access it in the tests.
$_ENV['APP_DIR'] = dirname(__DIR__);
// clear cache files
require $_ENV['APP_DIR'] . '/bin/clear.php';
// set the resource client
$GLOBALS['RESOURCE'] = Injector::create([new AppModule('test')])->getInstance('\\BEAR\\Resource\\ResourceInterface');
 /**
  * @param callable $moduleProvider
  * @param Cache    $cache
  * @param string   $cacheKey
  * @param string   $tmpDir
  *
  * @return Injector
  */
 public static function create(callable $moduleProvider, Cache $cache, $cacheKey, $tmpDir)
 {
     $module = new ModuleCacheModule($moduleProvider, $cacheKey, $tmpDir);
     $injector = Injector::create([$module], $cache, $tmpDir)->enableBindCache();
     return $injector;
 }