1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-01 11:30:16 +02:00

added "array" argument type

This commit is contained in:
Oliver Vogel
2014-07-27 11:40:50 +02:00
parent 45099a0c78
commit 837983c825
2 changed files with 25 additions and 0 deletions

View File

@@ -113,6 +113,11 @@ class Argument
$message = sprintf('%s accepts only string values as argument %d.', $this->getCommandName(), $this->key + 1);
break;
case 'array':
$fail = ! is_array($value);
$message = sprintf('%s accepts only array as argument %d.', $this->getCommandName(), $this->key + 1);
break;
case 'closure':
$fail = ! is_a($value, '\Closure');
$message = sprintf('%s accepts only Closure as argument %d.', $this->getCommandName(), $this->key + 1);

View File

@@ -69,6 +69,26 @@ class ArgumentTest extends PHPUnit_Framework_TestCase
$arg->type('integer');
}
public function testTypeArrayPass()
{
$arg = new Argument($this->getMockedCommand(array()));
$arg->type('array');
$this->validateArgument($arg, null);
$arg = new Argument($this->getMockedCommand(array(array(1,2,3))));
$arg->type('array');
$this->validateArgument($arg, array(1,2,3));
}
/**
* @expectedException \Intervention\Image\Exception\InvalidArgumentException
*/
public function testTypeArrayFail()
{
$arg = new Argument($this->getMockedCommand(array('foo')));
$arg->type('array');
}
public function testTypeDigitPass()
{
$arg = new Argument($this->getMockedCommand(array()));