Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 18, 2019
1 parent 1b063b4 commit f843b8a
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions src/Console/DuskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -235,26 +207,14 @@ 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.
*
* @return void
*/
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();

Expand All @@ -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.
*
Expand All @@ -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.
*
Expand Down

0 comments on commit f843b8a

Please sign in to comment.