Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DCzajkowski committed Sep 28, 2017
1 parent 59226fc commit b22ee09
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions src/Console/Commands/AuthTestsMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AuthTestsMakeCommand extends Command
*
* @var string
*/
protected $name = 'make:auth-tests';
protected $name = 'make:auth-tests {--force : Overwrite existing views by default}';

/**
* The console command description.
Expand All @@ -32,17 +32,50 @@ class AuthTestsMakeCommand extends Command
'Feature/Auth/ResetPasswordTest.stub' => 'Feature/Auth/ResetPasswordTest.php',
];

/**
* Directories that must be created.
*
* @var array
*/
protected $directories = [
'tests/Feature/Auth',
];

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
if (! is_dir($directory = base_path('tests/Feature/Auth'))) {
mkdir($directory, 0755, true);
$this->createDirectories();

$this->publishTests();

$this->info('Authentication tests generated successfully.');
}

/**
* Create required directories.
*
* @return void
*/
public function createDirectories()
{
foreach ($this->directories as $dir) {
if (! is_dir($directory = base_path($dir))) {
mkdir($directory, 0755, true);
}
}
}

/**
* Publish all tests.
*
* @return void
*/
public function publishTests()
{
foreach ($this->tests as $key => $value) {
if (file_exists($test = base_path('tests/' . $value)) && ! $this->option('force')) {
if (! $this->confirm("The [{$value}] test already exists. Do you want to replace it?")) {
Expand All @@ -55,7 +88,5 @@ public function handle()
$test
);
}

$this->info('Authentication tests generated successfully.');
}
}

0 comments on commit b22ee09

Please sign in to comment.