mirror of
https://github.com/Intervention/image.git
synced 2025-08-20 04:31:24 +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);
|
$message = sprintf('%s accepts only string values as argument %d.', $this->getCommandName(), $this->key + 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'array':
|
||||||
|
$fail = ! is_array($value);
|
||||||
|
$message = sprintf('%s accepts only array as argument %d.', $this->getCommandName(), $this->key + 1);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'closure':
|
case 'closure':
|
||||||
$fail = ! is_a($value, '\Closure');
|
$fail = ! is_a($value, '\Closure');
|
||||||
$message = sprintf('%s accepts only Closure as argument %d.', $this->getCommandName(), $this->key + 1);
|
$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');
|
$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()
|
public function testTypeDigitPass()
|
||||||
{
|
{
|
||||||
$arg = new Argument($this->getMockedCommand(array()));
|
$arg = new Argument($this->getMockedCommand(array()));
|
||||||
|
Reference in New Issue
Block a user