Example #1
0
 /**
  * Refresh the application instance.
  *
  * @return void
  */
 protected function refreshApplication()
 {
     $this->app = $this->createApplication();
     $this->client = $this->createClient();
     $this->app->setRequestForConsoleEnvironment();
     $this->app->boot();
 }
Example #2
0
 /**
  * Initialize the Laravel Framework.
  *
  * @throws ModuleConfig
  */
 private function initialize()
 {
     // Store a reference to the database object
     // so the database connection can be reused during tests
     $oldDb = null;
     if ($this->app['db'] && $this->app['db']->connection()) {
         $oldDb = $this->app['db'];
     }
     // Store the current value for the router filters
     // so it can be reset after reloading the application
     $oldFiltersEnabled = null;
     if ($router = $this->app['router']) {
         $property = new \ReflectionProperty(get_class($router), 'filtering');
         $property->setAccessible(true);
         $oldFiltersEnabled = $property->getValue($router);
     }
     $this->app = $this->loadApplication();
     $this->kernel = $this->getStackedClient();
     $this->app->boot();
     // Reset the booted flag of the Application object
     // so the app will be booted again if it receives a new Request
     $property = new \ReflectionProperty(get_class($this->app), 'booted');
     $property->setAccessible(true);
     $property->setValue($this->app, false);
     if ($oldDb) {
         $this->app['db'] = $oldDb;
         Model::setConnectionResolver($this->app['db']);
     }
     if (!is_null($oldFiltersEnabled)) {
         $oldFiltersEnabled ? $this->app['router']->enableFilters() : $this->app['router']->disableFilters();
     }
     $this->module->setApplication($this->app);
 }
Example #3
0
 /**
  * Constructor.
  *
  * @param Application $app
  */
 public function __construct(Application $app)
 {
     $this->app = $app;
     $this->httpKernel = $this->app->make('Illuminate\\Contracts\\Http\\Kernel');
     $this->httpKernel->bootstrap();
     $this->app->boot();
     parent::__construct($this);
 }
 /**
  * Create an barebones Laravel application.
  */
 protected function createApplication()
 {
     $this->app = new Application(__DIR__ . '/../../..');
     $this->app->instance('config', new Repository([]));
     $this->app['config']->set('session.driver', 'array');
     $this->app['config']->set('database', ['fetch' => PDO::FETCH_CLASS, 'default' => 'sqlite', 'connections' => ['sqlite' => ['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '']], 'migrations' => 'migrations']);
     $this->app['config']->set('app', ['providers' => [FilesystemServiceProvider::class, FoundationServiceProvider::class, PipelineServiceProvider::class, SessionServiceProvider::class, ViewServiceProvider::class, DatabaseServiceProvider::class, MigrationServiceProvider::class]]);
     $this->app->registerConfiguredProviders();
     $this->app->boot();
 }
Example #5
0
 public function _before(\Codeception\TestCase $test)
 {
     $this->kernel = $this->getApplication();
     $this->kernel->boot();
     $this->kernel->setRequestForConsoleEnvironment();
     $this->client = new LaravelConnector($this->kernel);
     $this->client->followRedirects(true);
     if ($this->config['filters']) {
         $this->haveEnabledFilters();
     }
     if ($this->transactionCleanup()) {
         $this->kernel['db']->beginTransaction();
     }
 }
Example #6
0
 /**
  * Constructor.
  *
  * @param Application $app
  */
 public function __construct(Application $app)
 {
     $this->app = $app;
     $this->httpKernel = $this->app->make('Illuminate\\Contracts\\Http\\Kernel');
     $this->httpKernel->bootstrap();
     $this->app->boot();
     $url = $this->app->config->get('app.url', 'http://localhost');
     $this->app->instance('request', Request::createFromBase(SyfmonyRequest::create($url)));
     $components = parse_url($url);
     $host = isset($components['host']) ? $components['host'] : 'localhost';
     parent::__construct($this, ['HTTP_HOST' => $host]);
     $this->followRedirects(true);
     // Parent constructor sets this to false by default
 }
Example #7
0
 /**
  * Create a new Console application.
  *
  * @param  \Illuminate\Foundation\Application  $app
  * @return \Illuminate\Console\Application
  */
 public static function make($app)
 {
     $app->boot();
     $console = with($console = new static('Laravel Framework', $app::VERSION))->setLaravel($app)->setExceptionHandler($app['exception'])->setAutoExit(false);
     $app->instance('artisan', $console);
     return $console;
 }
Example #8
0
 public function boot()
 {
     $this->registerIlluminateProviders();
     $this->registerCollejoProviders();
     $this->registerAliases();
     parent::boot();
 }
Example #9
0
 /**
  * Refresh the application instance.
  *
  * @param \Illuminate\Foundation\Application $app Optionally provide your own unbooted
  *                                                Laravel Application instance. This
  *                                                parameter can largely be ignored and
  *                                                is used just for unit testing
  * @return void
  */
 public function refreshApplication($app = null)
 {
     $this->app = $app instanceof Application ? $app : $this->createApplication();
     $this->app->setRequestForConsoleEnvironment();
     $this->app->boot();
     if ($this->migrateDatabase) {
         $artisan = $this->app->make('artisan');
         try {
             $artisan->call('migrate:install');
         } catch (QueryException $e) {
             // migration table is already installed
         }
         $artisan->call('migrate:refresh');
         if ($this->seedDatabase) {
             $artisan->call('db:seed', array('--class' => $this->seedClass));
         }
     }
 }
 /**
  * Refresh the application instance.
  *
  * @return void
  */
 protected function refreshApplication()
 {
     $this->app = $this->createApplication();
     Facade::setFacadeApplication($this->app);
     $this->app['env'] = 'testing';
     $this->app['path.storage'] = __DIR__;
     $loader = $this->getMockBuilder('Illuminate\\Config\\LoaderInterface')->setMethods(array('load', 'exists', 'getNamespaces', 'cascadePackage'))->getMockForAbstractClass();
     $loader->method('load')->will($this->returnValue(array()));
     $loader->method('exists')->will($this->returnValue(true));
     $loader->method('getNamespaces')->will($this->returnValue(array()));
     $loader->method('cascadePackage')->will($this->returnValue(array()));
     $this->app['config'] = new Repository($loader, $this->app['env']);
     $this->app['cache'] = new CacheManager($this->app);
     $this->app['config']['cache.driver'] = 'array';
     $this->app['session'] = new SessionManager($this->app);
     $this->app['config']['session.driver'] = 'array';
     $this->app['session.store'] = $this->app['session']->driver();
     $this->app->boot();
 }
Example #11
0
 /**
  * Boot the application's service providers.
  *
  * @return void 
  * @static 
  */
 public static function boot()
 {
     \Illuminate\Foundation\Application::boot();
 }