From e012301c8596118578c4abef178955888d02b435 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Fri, 12 Dec 2014 16:45:28 +0100 Subject: [PATCH] bugfix --- src/Intervention/Image/Commands/Argument.php | 4 +++- tests/ArgumentTest.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Intervention/Image/Commands/Argument.php b/src/Intervention/Image/Commands/Argument.php index 1ee0c962..ee33dcef 100644 --- a/src/Intervention/Image/Commands/Argument.php +++ b/src/Intervention/Image/Commands/Argument.php @@ -52,8 +52,10 @@ class Argument $arguments = $this->command->arguments; if (is_array($arguments)) { - return array_key_exists($this->key, $arguments) ? $arguments[$this->key] : $default; + return isset($arguments[$this->key]) ? $arguments[$this->key] : $default; } + + return $default; } /** diff --git a/tests/ArgumentTest.php b/tests/ArgumentTest.php index 1a187c4e..54e4d5d8 100644 --- a/tests/ArgumentTest.php +++ b/tests/ArgumentTest.php @@ -397,6 +397,17 @@ class ArgumentTest extends PHPUnit_Framework_TestCase $arg->max(10); } + public function testValueDefault() + { + $arg = new Argument($this->getMockedCommand()); + $value = $arg->value('foo'); + $this->assertEquals('foo', $value); + + $arg = new Argument($this->getMockedCommand(array(null))); + $value = $arg->value('foo'); + $this->assertEquals('foo', $value); + } + private function validateArgument($argument, $value) { $this->assertInstanceOf('\Intervention\Image\Commands\Argument', $argument);