From 7ec3460d733f607870630788c69c16c0994b09f3 Mon Sep 17 00:00:00 2001 From: Reza Amini Date: Wed, 21 Jul 2021 13:02:09 +0430 Subject: [PATCH 1/3] Add --force flag to pest:test command --- src/Laravel/Commands/PestTestCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Laravel/Commands/PestTestCommand.php b/src/Laravel/Commands/PestTestCommand.php index 55d9dc3a..5c6196a5 100644 --- a/src/Laravel/Commands/PestTestCommand.php +++ b/src/Laravel/Commands/PestTestCommand.php @@ -21,7 +21,7 @@ final class PestTestCommand extends Command * * @var string */ - protected $signature = 'pest:test {name : The name of the file} {--unit : Create a unit test} {--dusk : Create a Dusk test} {--test-directory=tests : The name of the tests directory}'; + protected $signature = 'pest:test {name : The name of the file} {--unit : Create a unit test} {--dusk : Create a Dusk test} {--test-directory=tests : The name of the tests directory} {--force : Force create}'; /** * The console command description. @@ -56,7 +56,7 @@ final class PestTestCommand extends Command File::makeDirectory(dirname($target), 0777, true, true); } - if (File::exists($target)) { + if (File::exists($target) and !$this->option('force')) { throw new InvalidConsoleArgument(sprintf('%s already exist', $target)); } From 5e0a0855ea685872fe64602c4e7a01a48ab16492 Mon Sep 17 00:00:00 2001 From: Reza Amini Date: Wed, 21 Jul 2021 14:38:11 +0430 Subject: [PATCH 2/3] Add a better description --- src/Laravel/Commands/PestTestCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Laravel/Commands/PestTestCommand.php b/src/Laravel/Commands/PestTestCommand.php index 5c6196a5..c8eebcba 100644 --- a/src/Laravel/Commands/PestTestCommand.php +++ b/src/Laravel/Commands/PestTestCommand.php @@ -21,7 +21,7 @@ final class PestTestCommand extends Command * * @var string */ - protected $signature = 'pest:test {name : The name of the file} {--unit : Create a unit test} {--dusk : Create a Dusk test} {--test-directory=tests : The name of the tests directory} {--force : Force create}'; + protected $signature = 'pest:test {name : The name of the file} {--unit : Create a unit test} {--dusk : Create a Dusk test} {--test-directory=tests : The name of the tests directory} {--force : Overwrite the existing test file with the same name}'; /** * The console command description. From 595bbe32a48b8e419e70b3fb9d26076d46a05ba2 Mon Sep 17 00:00:00 2001 From: Reza Amini Date: Thu, 22 Jul 2021 01:41:12 +0430 Subject: [PATCH 3/3] Add bool to the condition --- src/Laravel/Commands/PestTestCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Laravel/Commands/PestTestCommand.php b/src/Laravel/Commands/PestTestCommand.php index c8eebcba..7561355b 100644 --- a/src/Laravel/Commands/PestTestCommand.php +++ b/src/Laravel/Commands/PestTestCommand.php @@ -56,7 +56,7 @@ final class PestTestCommand extends Command File::makeDirectory(dirname($target), 0777, true, true); } - if (File::exists($target) and !$this->option('force')) { + if (File::exists($target) and !(bool) $this->option('force')) { throw new InvalidConsoleArgument(sprintf('%s already exist', $target)); }