clearResolvedInstances() public static method

Clear all of the resolved instances.
public static clearResolvedInstances ( ) : void
return void
 /**
  * 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();
 }
 /**
  * @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);
 }
Exemplo n.º 3
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();
 }
 /**
  * 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);
     }
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
0
 protected function setUp()
 {
     parent::setUp();
     self::$functions = m::mock();
     $this->index = m::mock('Menthol\\Flexible\\Index');
     $this->model = m::mock('Husband')->makePartial();
     $this->client = m::mock('Elasticsearch\\Client');
     $this->model->shouldReceive('getTable')->once()->andReturn('Husbands');
     Facade::clearResolvedInstances();
     App::shouldReceive('make')->with('Elasticsearch')->once()->andReturn($this->client);
     App::shouldReceive('make')->with('menthol.flexible.index', m::type('array'))->once()->andReturn($this->index);
     $this->proxy = new Proxy($this->model);
     self::$functions->shouldReceive('date')->andReturn('9999');
 }
Exemplo n.º 7
0
 /**
  * Creates the application.
  *
  * Needs to be implemented by subclasses.
  *
  * @return \Symfony\Component\HttpKernel\HttpKernelInterface
  */
 public function createApplication()
 {
     $app = new Application();
     $app->detectEnvironment(array('local' => array('your-machine-name')));
     $app->bindInstallPaths($this->getApplicationPaths());
     $app['env'] = 'testing';
     $app->instance('app', $app);
     Facade::clearResolvedInstances();
     Facade::setFacadeApplication($app);
     $app->registerCoreContainerAliases();
     with($envVariables = new EnvironmentVariables($app->getEnvironmentVariablesLoader()))->load($app['env']);
     $app->instance('config', $config = new Repository($app->getConfigLoader(), $app['env']));
     $app->startExceptionHandling();
     date_default_timezone_set($this->getApplicationTimezone());
     $aliases = array_merge($this->getApplicationAliases(), $this->getPackageAliases());
     AliasLoader::getInstance($aliases)->register();
     Request::enableHttpMethodParameterOverride();
     $providers = array_merge($this->getApplicationProviders(), $this->getPackageProviders());
     $app->getProviderRepository()->load($app, $providers);
     $this->registerBootedCallback($app);
     return $app;
 }
Exemplo n.º 8
0
 /**
  * Construct an Index mock
  *
  * @return array
  */
 private function getMocks($index_prefix = '')
 {
     /**
      *
      * Expectation
      *
      */
     Facade::clearResolvedInstances();
     $client = m::mock('Elasticsearch\\Client');
     $config = m::mock('Menthol\\Flexible\\Config');
     App::shouldReceive('make')->with('Elasticsearch')->andReturn($client);
     App::shouldReceive('make')->with('Menthol\\Flexible\\Config')->andReturn($config);
     $config->shouldReceive('get')->with('elasticsearch.index_prefix', '')->andReturn($index_prefix);
     $proxy = m::mock('Menthol\\Flexible\\Proxy');
     $proxy->shouldReceive('getModel->getTable')->andReturn('Husband');
     $index = m::mock('Menthol\\Flexible\\Index', [$proxy], [m::BLOCKS => ['setName', 'setProxy']])->makePartial();
     return [$index, $proxy, $client, $config];
 }
Exemplo n.º 9
0
 public function restoreAfterRequest()
 {
     $this->make('config')->set($this->needBackupConfigs);
     // clear all, not just request
     Facade::clearResolvedInstances();
     foreach ($this->needBackUpAppAttributes as $attri) {
         //           echo "\n $attri\n";
         //if(is_array($this->$attri))
         //echo count($this->__oldValues[$attri]) - count($this->$attri);
         $this->{$attri} = $this->__oldValues[$attri];
     }
     foreach ($this->restoreTool as $tool) {
         $tool();
     }
     $this->bootedInRequest = false;
 }
Exemplo n.º 10
0
 /**
  *
  */
 public function it_shoud_reindex_on_model_delete()
 {
     /**
      *
      * Expectation
      *
      */
     Facade::clearResolvedInstances();
     Queue::shouldReceive('push')->with('Iverberk\\Larasearch\\Jobs\\DeleteJob', ['Husband:2'])->once();
     Queue::shouldReceive('push')->with('Iverberk\\Larasearch\\Jobs\\ReindexJob', ['Wife:2', 'Child:2', 'Toy:2'])->once();
     Config::shouldReceive('get')->with('/^larasearch::reversedPaths\\..*$/', array())->once()->andReturn(['', 'wife', 'children', 'children.toys']);
     $husband = \Husband::find(2);
     with(new Observer())->deleted($husband);
 }
Exemplo n.º 11
0
 protected function registerBaseFacades()
 {
     Facade::clearResolvedInstances();
     Facade::setFacadeApplication($this);
     class_alias('Illuminate\\Support\\Facades\\App', 'App');
     class_alias('Illuminate\\Support\\Facades\\Schema', 'Schema');
     class_alias('Illuminate\\Support\\Facades\\Event', 'Event');
     class_alias('Illuminate\\Support\\Facades\\DB', 'DB');
     class_alias('Illuminate\\Database\\Eloquent\\Model', 'Eloquent');
     class_alias('Illuminate\\Support\\Facades\\File', 'File');
     class_alias('Illuminate\\Support\\Facades\\Config', 'Config');
     class_alias('Illuminate\\Support\\Facades\\Blade', 'Blade');
     class_alias('Illuminate\\Support\\Facades\\View', 'View');
 }
Exemplo n.º 12
0
 /**
  * Resolve application core implementation.
  *
  * @param  \Illuminate\Foundation\Application  $app
  *
  * @return void
  */
 protected function resolveApplicationCore($app)
 {
     Facade::clearResolvedInstances();
     Facade::setFacadeApplication($app);
     $app->detectEnvironment(function () {
         return 'testing';
     });
 }
Exemplo n.º 13
0
 /**
  * After step hook.
  *
  * @param \Codeception\Step $step
  */
 public function _afterStep(\Codeception\Step $step)
 {
     \Illuminate\Support\Facades\Facade::clearResolvedInstances();
     parent::_afterStep($step);
 }
Exemplo n.º 14
0
 /**
  * After step hook.
  *
  * @param \Codeception\Step $step
  */
 public function _afterStep(Step $step)
 {
     Facade::clearResolvedInstances();
 }
Exemplo n.º 15
0
 /**
  * Boot Cubex, Setup Facades, & Service Providers
  */
 public function boot()
 {
     if ($this->_booted) {
         return null;
     }
     //Fix anything that hasnt been set by the projects bootstrap
     $this->prepareCubex();
     //Bind services
     $this->processConfiguration($this->getConfiguration());
     //Setup facades
     Facade::clearResolvedInstances();
     Facade::setFacadeApplication($this);
     FacadeLoader::register();
     //Setup Service Providers
     $serviceManager = new ServiceManager();
     $serviceManager->setCubex($this);
     $serviceManager->boot();
     $this->instance('service.manager', $serviceManager);
     $this->_booted = true;
 }
Exemplo n.º 16
0
 /**
  * Construct an Index mock
  *
  * @return array
  */
 private function getMocks($index_prefix = null)
 {
     /**
      *
      * Expectation
      *
      */
     Facade::clearResolvedInstances();
     Config::shouldReceive('get')->with('larasearch::elasticsearch.index_prefix', '')->andReturn($index_prefix);
     $client = m::mock('Elasticsearch\\Client');
     App::shouldReceive('make')->with('Elasticsearch')->andReturn($client);
     $proxy = m::mock('Iverberk\\Larasearch\\Proxy');
     $proxy->shouldReceive('getModel->getTable')->andReturn('Husband');
     $index = m::mock('Iverberk\\Larasearch\\Index', [$proxy])->makePartial();
     return [$index, $proxy, $client];
 }
Exemplo n.º 17
0
 protected function tearDownFacades()
 {
     Facade::setFacadeApplication(null);
     Facade::clearResolvedInstances();
     Mockery::close();
 }
Exemplo n.º 18
0
 /**
  * Refresh the application instance.
  */
 private function refreshApplication()
 {
     $this->application = $this->createApplication();
     Facade::clearResolvedInstances();
 }
Exemplo n.º 19
0
 /**
  * After step hook.
  *
  * @param \Codeception\Step $step
  */
 public function _afterStep(\Codeception\Step $step)
 {
     parent::_afterStep($step);
     Facade::clearResolvedInstances();
 }
Exemplo n.º 20
0
 public function tearDown()
 {
     Mockery::close();
     Facade::setFacadeApplication(null);
     Facade::clearResolvedInstances();
 }
Exemplo n.º 21
0
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application $app
  * @return void
  */
 public function bootstrap(Application $app)
 {
     Facade::clearResolvedInstances();
     Facade::setFacadeApplication($app);
     AliasLoader::getInstance($app->make('config')->get('app.aliases'))->register();
 }
Exemplo n.º 22
0
|
*/
if (isset($unitTesting)) {
    $app['env'] = $env = $testEnvironment;
}
/*
|--------------------------------------------------------------------------
| Load The Illuminate Facades
|--------------------------------------------------------------------------
|
| The facades provide a terser static interface over the various parts
| of the application, allowing their methods to be accessed through
| a mixtures of magic methods and facade derivatives. It's slick.
|
*/
Facade::clearResolvedInstances();
Facade::setFacadeApplication($app);
/*
|--------------------------------------------------------------------------
| Register Facade Aliases To Full Classes
|--------------------------------------------------------------------------
|
| By default, we use short keys in the container for each of the core
| pieces of the framework. Here we will register the aliases for a
| list of all of the fully qualified class names making DI easy.
|
*/
$app->registerCoreContainerAliases();
/*
|--------------------------------------------------------------------------
| Register The Environment Variables
Exemplo n.º 23
0
 /**
  * Initialize the Lumen framework.
  *
  * @throws ModuleConfig
  */
 protected function initializeLumen()
 {
     if ($this->booted) {
         Facade::clearResolvedInstances();
     }
     $this->app = $this->bootApplication();
     $this->app->instance('request', new Request());
     $this->client = new LumenConnector($this->app);
     $this->client->followRedirects(true);
     $this->revertErrorHandler();
 }
Exemplo n.º 24
0
 /**
  * Refresh the application instance.
  *
  * @return void
  */
 protected function refreshApplication()
 {
     putenv('APP_ENV=testing');
     $this->app = $this->createApplication();
     Facade::clearResolvedInstances();
 }
Exemplo n.º 25
0
 /**
  * After step hook.
  *
  * @param \Codeception\Step $step
  */
 public function _afterStep(Step $step)
 {
     parent::_beforeStep($step);
     $this->app['session.store']->save();
     Facade::clearResolvedInstances();
 }
 public function setUp()
 {
     Facade::clearResolvedInstances();
 }
 public function tearDown()
 {
     Facade::clearResolvedInstances();
 }
Exemplo n.º 28
0
 /**
  * @param array $alias
  */
 public function registerFacade(array $alias)
 {
     Facade::clearResolvedInstances();
     Facade::setFacadeApplication($this);
     AliasLoader::getInstance($alias)->register();
 }
Exemplo n.º 29
0
 /**
  * @test
  */
 public function it_should_reindex_on_model_delete()
 {
     /**
      *
      * Expectation
      *
      */
     Facade::clearResolvedInstances();
     Queue::shouldReceive('push')->with('Menthol\\Flexible\\Jobs\\DeleteJob', ['Husband:2'])->once();
     $config = m::mock('Menthol\\Flexible\\Config');
     App::shouldReceive('make')->with('Menthol\\Flexible\\Config')->andReturn($config);
     $config->shouldReceive('get')->with('/^reversedPaths\\..*$/', [])->once()->andReturn(['', 'wife', 'children', 'children.toys']);
     Queue::shouldReceive('push')->with('Menthol\\Flexible\\Jobs\\ReindexJob', ['Wife:2', 'Child:2', 'Toy:2'])->once();
     $husband = \Husband::find(2);
     with(new Observer())->deleted($husband);
 }