From 4546861ba5293f1eedfe9613d0d964c1a5bda833 Mon Sep 17 00:00:00 2001 From: alnutile Date: Fri, 4 Dec 2015 14:42:39 -0500 Subject: [PATCH] Failing unit test on codeship not sure why yet --skip-ui --- src/BaseDeployer.php | 11 +++++++++-- tests/BuildArrayFromEnvTest.php | 20 +++++++++++++++++++- tests/PullEnvTest.php | 4 ++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/BaseDeployer.php b/src/BaseDeployer.php index 86018ac..904f4e7 100644 --- a/src/BaseDeployer.php +++ b/src/BaseDeployer.php @@ -21,20 +21,26 @@ class BaseDeployer { public function checkForFile($path = false) { - $path = ($path) ? $path : $this->filePath; + $path = ($path) ? $path : $this->getFilePath(); if(!$this->getFilesystem()->exists($path)) throw new \Exception(sprintf("No file found at -> %s", $path)); } - public function setFilePath($filePath) + public function setFilePath($filePath = false) { + if($filePath == false) + $filePath = base_path(); + $this->filePath = $filePath; } public function getFilePath() { + if($this->filePath == null) + $this->setFilePath(); + return $this->filePath; } @@ -73,6 +79,7 @@ protected function makeEnvArrayFromFile($path_with_name = false) { $path_with_name = ($path_with_name) ? $path_with_name : $this->filePath; + /** * Thanks to Dotenv library by vlucas */ diff --git a/tests/BuildArrayFromEnvTest.php b/tests/BuildArrayFromEnvTest.php index 5dcd3c9..74d4dfe 100644 --- a/tests/BuildArrayFromEnvTest.php +++ b/tests/BuildArrayFromEnvTest.php @@ -10,7 +10,8 @@ class BuildArrayFromEnvTest extends \TestCase */ public function should_load_file() { - $this->markTestSkipped("Just not needed on codship"); + $this->markTestSkipped("Just not needed on codeship"); + $ba = (new BuildArrayFromEnv())->setTarget('dev'); $results = $ba->getEnv(); @@ -47,6 +48,23 @@ public function should_include_default_settings_as_well_not_just_replaced_ones() $this->assertCount(2, $ba->getTargetEnv()); } + /** + * @test + */ + public function make_sure_false_has_no_quotes() + { + $ba = (new BuildArrayFromEnv())->setTarget('dev'); + $ba->setEnv( + [ + "#@dev=false", + "#@stage=false", + "APP_ENV=true", + ]); + $ba->buildOutNewEnvArray(); + + $this->assertEquals('APP_ENV=false', $ba->getTargetEnv()[0]); + } + /** * @test */ diff --git a/tests/PullEnvTest.php b/tests/PullEnvTest.php index 1cf1216..a7f6eb5 100644 --- a/tests/PullEnvTest.php +++ b/tests/PullEnvTest.php @@ -3,9 +3,9 @@ if(!function_exists('base_path')) { - function base_path() + function base_path($arg = '') { - return ''; + return __DIR__ . '/../' . $arg; } } class PullEnvTest extends \TestCase {