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:
@@ -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);
|
||||
|
@@ -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()));
|
||||
|
Reference in New Issue
Block a user