1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111:
<?php
namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
use Guzzle\Http\Message\EntityEnclosingRequest;
use Guzzle\Service\Description\Operation;
use Guzzle\Service\Description\Parameter;
use Guzzle\Service\Description\SchemaValidator;
use Guzzle\Service\Command\OperationCommand;
use Guzzle\Tests\Service\Mock\Command\MockCommand;
use Guzzle\Tests\Service\Mock\MockClient;
abstract class AbstractVisitorTestCase extends \Guzzle\Tests\GuzzleTestCase
{
protected $command;
protected $request;
protected $param;
protected $validator;
public function setUp()
{
$this->command = new MockCommand();
$this->request = new EntityEnclosingRequest('POST', 'http://www.test.com/some/path.php');
$this->validator = new SchemaValidator();
}
protected function getCommand($location)
{
$command = new OperationCommand(array(), $this->getNestedCommand($location));
$command->setClient(new MockClient());
return $command;
}
protected function getNestedCommand($location)
{
return new Operation(array(
'httpMethod' => 'POST',
'parameters' => array(
'foo' => new Parameter(array(
'type' => 'object',
'location' => $location,
'sentAs' => 'Foo',
'required' => true,
'properties' => array(
'test' => array(
'type' => 'object',
'required' => true,
'properties' => array(
'baz' => array(
'type' => 'boolean',
'default' => true
),
'jenga' => array(
'type' => 'string',
'default' => 'hello',
'sentAs' => 'Jenga_Yall!',
'filters' => array('strtoupper')
)
)
),
'bar' => array('default' => 123)
),
'additionalProperties' => array(
'type' => 'string',
'filters' => array('strtoupper'),
'location' => $location
)
)),
'arr' => new Parameter(array(
'type' => 'array',
'location' => $location,
'items' => array(
'type' => 'string',
'filters' => array('strtoupper')
)
)),
)
));
}
protected function getCommandWithArrayParamAndFilters()
{
$operation = new Operation(array(
'httpMethod' => 'POST',
'parameters' => array(
'foo' => new Parameter(array(
'type' => 'string',
'location' => 'query',
'sentAs' => 'Foo',
'required' => true,
'default' => 'bar',
'filters' => array('strtoupper')
)),
'arr' => new Parameter(array(
'type' => 'array',
'location' => 'query',
'sentAs' => 'Arr',
'required' => true,
'default' => array(123, 456, 789),
'filters' => array(array('method' => 'implode', 'args' => array(',', '@value')))
))
)
));
$command = new OperationCommand(array(), $operation);
$command->setClient(new MockClient());
return $command;
}
}