diff --git a/src/Console/DuskCommand.php b/src/Console/DuskCommand.php index 8d22b1b8c..b0b9a86fb 100644 --- a/src/Console/DuskCommand.php +++ b/src/Console/DuskCommand.php @@ -195,34 +195,6 @@ protected function setupDuskEnvironment() $this->setupSignalHandler(); } - /** - * Setup the SIGINT signal handler for CTRL+C exits. - * - * @return void - */ - protected function setupSignalHandler() - { - pcntl_async_signals(true); - - pcntl_signal(SIGINT, function () { - $this->teardownDuskEnviroment(); - }); - } - - /** - * Restore the original environment. - * - * @return void - */ - protected function teardownDuskEnviroment() - { - $this->removeConfiguration(); - - if (file_exists(base_path($this->duskFile())) && file_exists(base_path('.env.backup'))) { - $this->restoreEnvironment(); - } - } - /** * Backup the current environment file. * @@ -235,18 +207,6 @@ protected function backupEnvironment() copy(base_path($this->duskFile()), base_path('.env')); } - /** - * Restore the backed-up environment file. - * - * @return void - */ - protected function restoreEnvironment() - { - copy(base_path('.env.backup'), base_path('.env')); - - unlink(base_path('.env.backup')); - } - /** * Refresh the current environment variables. * @@ -254,7 +214,7 @@ protected function restoreEnvironment() */ protected function refreshEnvironment() { - // BC fix to support Dotenv ^2.2 + // BC fix to support Dotenv ^2.2... if (! method_exists(Dotenv::class, 'create')) { (new Dotenv(base_path()))->overload(); @@ -281,6 +241,34 @@ protected function writeConfiguration() $this->hasPhpUnitConfiguration = true; } + /** + * Setup the SIGINT signal handler for CTRL+C exits. + * + * @return void + */ + protected function setupSignalHandler() + { + pcntl_async_signals(true); + + pcntl_signal(SIGINT, function () { + $this->teardownDuskEnviroment(); + }); + } + + /** + * Restore the original environment. + * + * @return void + */ + protected function teardownDuskEnviroment() + { + $this->removeConfiguration(); + + if (file_exists(base_path($this->duskFile())) && file_exists(base_path('.env.backup'))) { + $this->restoreEnvironment(); + } + } + /** * Remove the Dusk PHPUnit configuration. * @@ -293,6 +281,18 @@ protected function removeConfiguration() } } + /** + * Restore the backed-up environment file. + * + * @return void + */ + protected function restoreEnvironment() + { + copy(base_path('.env.backup'), base_path('.env')); + + unlink(base_path('.env.backup')); + } + /** * Get the name of the Dusk file for the environment. *