Esempio n. 1
0
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application $app
  * @return void
  */
 public function bootstrap(Application $app)
 {
     /** @var \Illuminate\Foundation\Application $app*/
     $env = $app->environment();
     $filesystem = $this->files = new Filesystem();
     $loader = new FileLoader($filesystem, $app['path.config']);
     $config = new Repository($loader, $filesystem, $env);
     $loader->setRepository($config);
     $app->instance('config', $config);
     $configuredLoader = $app['config']->get('laradic_config.loader');
     if (isset($configuredLoader) && $configuredLoader !== 'file') {
         if ($configuredLoader === 'db') {
             $loader = new DatabaseLoader($filesystem, $app['path.config']);
             $config->setLoader($loader);
             $app->booted(function () use($app, $loader, $config) {
                 $loader->setDatabase($app['db']->connection());
                 $loader->setDatabaseTable($app['config']->get('laradic_config.loaders.db.table'));
             });
             $loader->setRepository($config);
         }
     }
     if (file_exists($cached = $app->getCachedConfigPath()) && !$app->runningInConsole()) {
         $items = (require $cached);
         $loadedFromCache = true;
     }
     if (!isset($loadedFromCache)) {
         # $this->loadConfigurationFiles($app, $config);
     }
     date_default_timezone_set($config['app.timezone']);
     mb_internal_encoding('UTF-8');
 }
 public function testLoader()
 {
     $path = __DIR__ . '/fixture';
     $result = ['foo' => 'bar'];
     $fs = m::mock('Illuminate\\Filesystem\\Filesystem')->shouldIgnoreMissing()->shouldReceive('exists')->zeroOrMoreTimes()->with($path . '/laradic_test.php')->andReturn(true)->getMock();
     $fs->shouldReceive('getRequire')->zeroOrMoreTimes()->with($path . '/laradic_test.php')->andReturn($result)->getMock();
     $fileLoader = new FileLoader($fs, $path);
     $this->assertEquals($result, $fileLoader->load('', 'laradic_test'));
 }
Esempio n. 3
0
 protected function _createLoadFileTest($path, $name, $ext)
 {
     $result = ['foo' => 'bar'];
     $fs = m::mock('Illuminate\\Filesystem\\Filesystem')->shouldIgnoreMissing()->shouldReceive('exists')->zeroOrMoreTimes()->with($path . '/' . $name . $ext)->andReturn(true)->getMock();
     $fs->shouldReceive('getRequire')->zeroOrMoreTimes()->with($path . '/' . $name . $ext)->andReturn($result)->getMock();
     $fs->shouldReceive('get')->zeroOrMoreTimes()->with($path . '/' . $name . $ext)->andReturn('foo: bar')->getMock();
     $loader = new FileLoader($fs, $path);
     $this->assertEquals($result, $loader->load('', $name));
 }