示例#1
0
 public function __construct($values = array())
 {
     parent::__construct();
     static::$app = $this;
     foreach ($values as $key => $value) {
         $this[$key] = $value;
     }
     Facade::setFacadeApplication($this);
     // register the configserviceprovider so we can access the config
     $this->register(new ConfigServiceProvider());
     // grab the providers from the config and load them
     $providers = $this['config']->get('app/providers');
     foreach ($providers as $provider) {
         $this->register(new $provider());
     }
     // set the locale (https://github.com/silexphp/Silex/issues/983)
     $locale = $values['locale'];
     if ($this['translator']) {
         $this['translator']->setlocale($locale);
     }
     // register fieldtypes from config
     $fieldTypesConfig = $this['config']->get('fieldtypes');
     if ($fieldTypesConfig) {
         $this['fieldtypes'] = $this['fieldtypes.factory']->fromConfig($fieldTypesConfig);
     }
     // register contenttypes from config
     $contentTypeConfig = $this['config']->get('contenttypes');
     if ($contentTypeConfig) {
         $this['contenttypes'] = $this['contenttypes.factory']->fromConfig($contentTypeConfig);
     }
 }
示例#2
0
 /**
  * Send the given request through the middleware / router.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 protected function sendRequestThroughRouter($request)
 {
     $this->app->instance('request', $request);
     Facade::clearResolvedInstance('request');
     $this->bootstrap();
     // If administration panel is attempting to be displayed,
     // we don't need any response
     if (is_admin()) {
         return;
     }
     // Get response on `template_include` filter so the conditional functions work correctly
     add_filter('template_include', function ($template) use($request) {
         // If the template is not index.php, then don't output anything
         if ($template !== get_template_directory() . '/index.php') {
             return $template;
         }
         try {
             $response = (new Pipeline($this->app))->send($request)->through($this->app->shouldSkipMiddleware() ? [] : $this->middleware)->then($this->dispatchToRouter());
         } catch (Exception $e) {
             $this->reportException($e);
             $response = $this->renderException($request, $e);
         } catch (Throwable $e) {
             $this->reportException($e = new FatalThrowableError($e));
             $response = $this->renderException($request, $e);
         }
         $this->app['events']->fire('kernel.handled', [$request, $response]);
         return $template;
     }, PHP_INT_MAX);
 }
示例#3
0
 /**
  * Bootstrap the test environemnt:
  * - Create an application instance and register it within itself.
  * - Register the package service provider with the app.
  * - Set the APP facade.
  *
  * @return void
  */
 public function setUp()
 {
     $app = new Application();
     $app->instance('app', $app);
     $app->register('Codesleeve\\LaravelStapler\\LaravelStaplerServiceProvider');
     Facade::setFacadeApplication($app);
 }
示例#4
0
 /**
  * Bootstrap the test environemnt:
  * - Create an application instance and register it within itself.
  * - Register the package service provider with the app.
  * - Set the APP facade.
  *
  * @return void
  */
 public function setUp()
 {
     $app = new Application();
     $app->instance('app', $app);
     $app->register('Ideil\\LaravelFileOre\\LaravelFileOreServiceProvider');
     Facade::setFacadeApplication($app);
 }
示例#5
0
 public function bootstrap(Application $app, $config)
 {
     \Illuminate\Support\Facades\Facade::clearResolvedInstances();
     \Illuminate\Support\Facades\Facade::setFacadeApplication($app);
     #注册别名并设置自动加载器
     \Illuminate\Foundation\AliasLoader::getInstance($config['app_aliases'])->register();
 }
示例#6
0
 /**
  * {@inheritDoc}
  */
 protected static function resolveFacadeInstance($name)
 {
     if (!is_object($name) && !static::$app->bound($name) && ($instance = static::getFacadeInstance()) !== null) {
         static::$app->instance($name, $instance);
     }
     return parent::resolveFacadeInstance($name);
 }
 /**
  * After each scenario, reboot the kernel.
  */
 public function reboot()
 {
     Facade::clearResolvedInstances();
     $lumen = new LumenBooter($this->app->basePath());
     $this->context->getSession('lumen')->getDriver()->reboot($this->app = $lumen->boot());
     $this->setAppOnContext();
 }
示例#8
0
 protected function getApp($service = null)
 {
     if ($service) {
         return Facade::getFacadeApplication()->make($service);
     }
     return Facade::getFacadeApplication();
 }
示例#9
0
文件: Ioc.php 项目: krisanalfa/worx
 public function register()
 {
     $this->app->container->singleton('ioc', function () {
         return new Container();
     });
     Facade::setFacadeApplication($this->app->ioc);
 }
示例#10
0
 public static function create()
 {
     $instance = new self();
     // Swap the Facade app with our container (to use these mocks)
     Facade::setFacadeApplication($instance->app);
     return $instance->app;
 }
 /**
  * @test
  */
 public function it_should_get_a_proxy()
 {
     /**
      *
      * Set
      *
      */
     $proxy = m::mock('Iverberk\\Larasearch\\proxy');
     /**
      *
      * Expectation
      *
      */
     Facade::clearResolvedInstances();
     \Husband::clearProxy();
     App::shouldReceive('make')->with('iverberk.larasearch.proxy', m::type('Illuminate\\Database\\Eloquent\\Model'))->andReturn($proxy);
     /**
      *
      *
      * Assertion
      *
      */
     $proxy1 = \Husband::getProxy();
     $this->assertSame($proxy, $proxy1);
     $proxy2 = \Husband::getProxy();
     $this->assertSame($proxy, $proxy2);
 }
示例#12
0
 /**
  * Send the given request through the middleware / router.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 protected function sendRequestThroughRouter($request)
 {
     $this->app->instance('request', $request);
     Facade::clearResolvedInstance('request');
     $this->bootstrap();
     return (new Pipeline($this->app))->send($request)->through($this->middleware)->then($this->dispatchToRouter());
 }
示例#13
0
 public static function __callStatic($method, $args)
 {
     // subhelper
     if (empty($args)) {
         return LaravelFacade::getFacadeApplication()->helpers->subhelper($method);
     }
 }
 public function setUp()
 {
     $app = M::mock('Application');
     $app = $app->shouldReceive('make')->with('path.public')->andReturn('tmp');
     $app = $app->shouldReceive('make')->with('path')->andReturn('tests');
     $app = $app->mock();
     Facade::setFacadeApplication($app);
 }
 public function testMapping()
 {
     Facade::setFacadeApplication(new ApplicationStub());
     $configuration = ['driver' => 'sqlite', 'database' => 'db', 'username' => 'somedude', 'prefix' => 'mitch_', 'charset' => 'whatevs'];
     $expected = ['driver' => 'pdo_sqlite', 'path' => 'path/database/db.sqlite', 'user' => $configuration['username']];
     $actual = $this->sqlMapper->map($configuration);
     $this->assertEquals($expected, $actual);
 }
示例#16
0
 /**
  * Send the given request through the middleware / router.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 protected function sendRequestThroughRouter($request)
 {
     $this->app->instance('request', $request);
     Facade::clearResolvedInstance('request');
     $this->bootstrap();
     $shouldSkipMiddleware = $this->app->bound('middleware.disable') && $this->app->make('middleware.disable') === true;
     return (new Pipeline($this->app))->send($request)->through($shouldSkipMiddleware ? [] : $this->middleware)->then($this->dispatchToRouter());
 }
示例#17
0
 /**
  * Creates the application.
  *
  * @return \Symfony\Component\HttpKernel\HttpKernelInterface
  */
 public function createApplication()
 {
     Facade::setFacadeApplication($app = new Application());
     $app['env'] = 'testing';
     $app['path'] = 'app_path';
     $app['path.config'] = 'config_path';
     return $app;
 }
 /** @test */
 public function it_returns_the_schema_builder()
 {
     $migration = new MigrationStub();
     $mock = Mockery::mock('Illuminate\\Database\\Connection');
     Facade::setFacadeApplication(['db' => $mock]);
     $mock->shouldReceive('getSchemaBuilder')->once()->andReturn('foo');
     $this->assertEquals('foo', $migration->getSchemaBuilder());
 }
 /**
  * setUp method.
  */
 public function setUp()
 {
     // Bootstrap the application container
     $app = new Application();
     $app->instance('app', $app);
     $app->register('Codesleeve\\FixtureL4\\FixtureL4ServiceProvider');
     Facade::setFacadeApplication($app);
 }
 protected function setUp()
 {
     $this->controller = new CommodeControllerTestSubject();
     $this->applicationMock = $this->getMock('Illuminate\\Foundation\\Application', ['make']);
     $this->requestMock = $this->getMock('Illuminate\\Http\\Request', ['ajax']);
     $this->resolver = new Resolver($this->applicationMock);
     Facade::setFacadeApplication($this->applicationMock);
     parent::setUp();
 }
示例#21
0
 public function __construct(array $attributes)
 {
     $this->encrypter = new Encrypter('088409730f085dd15e8e3a7d429dd185', 'AES-256-CBC');
     $app = new Container();
     $app->singleton('app', 'Illuminate\\Container\\Container');
     $app->singleton('config', 'Illuminate\\Config\\Repository');
     $app['config']->set('elocrypt.prefix', '__ELOCRYPT__:');
     Facade::setFacadeApplication($app);
     parent::__construct($attributes);
 }
示例#22
0
 public function setUp()
 {
     parent::setUp();
     // reset configs
     Facade::clearResolvedInstance('reactjs');
     $this->app['config']->set('basepath', '');
     $this->app['config']->set('react_src', '');
     $this->app['config']->set('src_files', []);
     $this->app['config']->set('react_prefix', '');
     $this->app['config']->set('components_prefix', '');
 }
 public function testAllWorks()
 {
     $this->prepareFakeData();
     $app = m::mock('AppMock');
     $app->shouldReceive('instance')->once()->andReturn($app);
     \Illuminate\Support\Facades\Facade::setFacadeApplication($app);
     \Illuminate\Support\Facades\Config::swap($config = m::mock('ConfigMock'));
     $config->shouldReceive('get')->once()->andReturn(5);
     $objs = $this->r->all();
     $this->assertEquals(5, count($objs));
 }
示例#24
0
 /**
  * Create do provider.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  */
 public function __construct($app)
 {
     parent::__construct($app);
     // Trocar instancias
     foreach ($this->instances as $provider => $classServiceProvider) {
         // Limpar facade
         Facade::clearResolvedInstance($provider);
         // Trocar / Criar
         $this->app->instance($provider, new $classServiceProvider($app));
     }
 }
示例#25
0
 public function setUp()
 {
     parent::setUp();
     /** @var \Illuminate\Foundation\Application|\PHPUnit_Framework_MockObject_Builder_InvocationMocker $app */
     $app = $this->getMockBuilder('\\Illuminate\\Foundation\\Application')->disableOriginalConstructor()->getMock();
     $app->method('make')->willReturn('\\GionniValeriana\\laravelAdminlte\\Adminlte');
     Illuminate\Container\Container::setInstance(new Container());
     Facade::setFacadeApplication($app);
     $this->MockedBaseMenuItem = $this->getMockBuilder('\\SleepingOwl\\Admin\\Menu\\MenuItem')->disableOriginalConstructor()->getMock();
     $this->MockedMenuItem = $this->getMockBuilder('\\GionniValeriana\\laravelAdminlte\\MenuItem')->disableOriginalConstructor()->getMock();
 }
 /**
  * Stop the application
  *
  * @return void
  */
 public function stopApplication()
 {
     if ($this->hasApplicationBeenStarted()) {
         foreach ($this->beforeApplicationDestroyedCallbacks as $callback) {
             call_user_func($callback);
         }
         $this->app->flush();
         $this->app = null;
         Facade::clearResolvedInstances();
         Facade::setFacadeApplication(null);
     }
 }
示例#27
0
 /**
  * Register the facades for the application.
  */
 public function withFacades()
 {
     Facade::setFacadeApplication($this);
     class_alias('Illuminate\\Support\\Facades\\DB', 'DB');
     class_alias('Illuminate\\Support\\Facades\\App', 'App');
     class_alias('Illuminate\\Support\\Facades\\File', 'File');
     class_alias('Illuminate\\Support\\Facades\\Cache', 'Cache');
     class_alias('Illuminate\\Support\\Facades\\Event', 'Event');
     class_alias('Illuminate\\Support\\Facades\\Session', 'Session');
     class_alias('Illuminate\\Support\\Facades\\Request', 'Request');
     class_alias('Illuminate\\Support\\Facades\\Response', 'Response');
 }
示例#28
0
 public function setUp()
 {
     with(new UserSeeder())->run();
     $app = new ApplicationStub();
     \Illuminate\Support\Facades\Facade::setFacadeApplication($app);
     if (!function_exists('trans')) {
         function trans($key)
         {
             return $key;
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $app = new Container();
     $app->singleton('app', 'Illuminate\\Config\\Repository');
     $app->singleton('config', 'Illuminate\\Config\\Repository');
     Facade::setFacadeApplication($app);
     $app['app']->set('aliases.Config', Illuminate\Support\Facades\Config::class);
     $api_key = empty(getenv('YANDEX_API_KEY')) ? include_once 'yandex.api.key.php' : getenv('YANDEX_API_KEY');
     $app['config']->set('services.yandex-translate.key', $api_key);
     $this->translate = new Translate();
 }
示例#30
0
 /**
  * Setup the test environment.
  *
  * @return void
  */
 protected function setUp()
 {
     if (!$this->app) {
         $this->refreshApplication();
     }
     $this->setUpTraits();
     foreach ($this->afterApplicationCreatedCallbacks as $callback) {
         call_user_func($callback);
     }
     Facade::clearResolvedInstances();
     Model::setEventDispatcher($this->app['events']);
     $this->setUpHasRun = true;
 }