From f4565ca12a9793b0116ed423aa2aa8b8ac1e2fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Guzm=C3=A1n=20Hermandez?= Date: Thu, 2 Apr 2020 16:04:33 -0500 Subject: [PATCH 1/2] Makes the project variable Optional --- src/Console/Commands/CreateVersionFile.php | 4 ++-- .../Commands/CreateVersionFileCommandTest.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Console/Commands/CreateVersionFile.php b/src/Console/Commands/CreateVersionFile.php index 47e5a00..e85469a 100644 --- a/src/Console/Commands/CreateVersionFile.php +++ b/src/Console/Commands/CreateVersionFile.php @@ -41,7 +41,7 @@ public function handle(Factory $validator) VersionFile::generate([ 'sha' => $options['sha'], 'time' => $options['time'], - 'project' => $options['project'], + 'project' => $options['project']?? '', 'branch' => $options['branch'], ]); @@ -58,7 +58,7 @@ private function validateOptions(Factory $validator) return $validator->make($this->options(), [ 'sha' => 'required', 'time' => 'required', - 'project' => 'required', + 'project' => 'nullable', 'branch' => 'required', ])->validate(); } diff --git a/tests/Commands/CreateVersionFileCommandTest.php b/tests/Commands/CreateVersionFileCommandTest.php index 7082f61..532f799 100644 --- a/tests/Commands/CreateVersionFileCommandTest.php +++ b/tests/Commands/CreateVersionFileCommandTest.php @@ -35,6 +35,25 @@ public function can_create_version_file() $this->assertJsonStringEqualsJsonFile(VersionFile::path(), json_encode($input)); } + /** @test */ + public function can_create_version_file_without_project_variable() + { + $input = [ + 'sha' => 'abcdef', + 'time' => '20200315170330', + 'branch' => 'master', + ]; + + $this->artisan('app-version:create', [ + '--sha' => $input['sha'], + '--time' => $input['time'], + '--branch' => $input['branch'], + ])->assertExitCode(0); + + $this->assertFileExists(VersionFile::path()); + $this->assertJsonStringEqualsJsonFile(VersionFile::path(), json_encode($input)); + } + protected function tearDown(): void { VersionFile::delete(); From 887415124c73d128dcdc932f1b16b43ef7739236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Guzm=C3=A1n=20Hermandez?= Date: Thu, 2 Apr 2020 16:10:27 -0500 Subject: [PATCH 2/2] Update CreateVersionFileCommandTest.php --- tests/Commands/CreateVersionFileCommandTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Commands/CreateVersionFileCommandTest.php b/tests/Commands/CreateVersionFileCommandTest.php index 532f799..d903a88 100644 --- a/tests/Commands/CreateVersionFileCommandTest.php +++ b/tests/Commands/CreateVersionFileCommandTest.php @@ -42,6 +42,7 @@ public function can_create_version_file_without_project_variable() 'sha' => 'abcdef', 'time' => '20200315170330', 'branch' => 'master', + 'project' => '', ]; $this->artisan('app-version:create', [