app) { $this->refreshApplication(); } } /** * Clean up the testing environment before the next test. * * @return void */ public function tearDown() { if ($this->app) { foreach ($this->beforeApplicationDestroyedCallbacks as $callback) { call_user_func($callback); } $this->app->flush(); $this->app = null; } if (property_exists($this, 'serverVariables')) { $this->serverVariables = []; } if (class_exists('Mockery')) { Mockery::close(); } } /** * Register a callback to be run before the application is destroyed. * * @param callable $callback * @return void */ protected function beforeApplicationDestroyed(callable $callback) { $this->beforeApplicationDestroyedCallbacks[] = $callback; } }