Skip to content

Commit

Permalink
Replace Serializer test with serializer compliance test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeskew committed Jun 18, 2015
1 parent fc69926 commit 0db6dcd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 41 deletions.
41 changes: 0 additions & 41 deletions tests/Api/Serializer/QuerySerializerTest.php
Expand Up @@ -46,45 +46,4 @@ function () {}
$this->assertEquals('http://foo.com', (string) $request->getUri());
$this->assertEquals('Action=foo&Version=1&baz=', (string) $request->getBody());
}

public function testUsesLocationNameToIdentifyMembersOfFlattenedLists()
{
$service = new Service(
[
'metadata'=> [
'protocol' => 'query',
'apiVersion' => '1'
],
'operations' => [
'foo' => [
'http' => ['httpMethod' => 'POST'],
'input' => [
'type' => 'structure',
'members' => [
'bars' => [
'type' => 'list',
'member' => [
'type' => 'string',
'locationName' => 'bar',
],
'flattened' => true,
],
]
]
]
]
],
function () {}
);

$q = new QuerySerializer($service, 'http://foo.com');
$cmd = new Command('foo', ['bars' => ['a', 'list', 'of', 'strings']]);
$request = $q($cmd);
$this->assertEquals('POST', $request->getMethod());
$this->assertEquals('http://foo.com', (string) $request->getUri());
$this->assertEquals(
'Action=foo&Version=1&bar.1=a&bar.2=list&bar.3=of&bar.4=strings',
(string) $request->getBody()
);
}
}
53 changes: 53 additions & 0 deletions tests/Api/test_cases/protocols/input/query.json
Expand Up @@ -186,6 +186,59 @@
}
]
},
{
"description": "Flattened list with LocationName",
"metadata": {
"protocol": "query",
"apiVersion": "2014-01-01"
},
"shapes": {
"InputShape": {
"type": "structure",
"members": {
"ScalarArg": {
"shape": "StringType"
},
"ListArg": {
"shape": "ListType"
}
}
},
"ListType": {
"type": "list",
"member": {
"shape": "StringType",
"locationName": "ListArgLocation"
},
"flattened": true
},
"StringType": {
"type": "string"
}
},
"cases": [
{
"given": {
"input": {
"shape": "InputShape"
},
"name": "OperationName"
},
"params": {
"ScalarArg": "foo",
"ListArg": [
"a",
"b",
"c"
]
},
"serialized": {
"uri": "/",
"body": "Action=OperationName&Version=2014-01-01&ScalarArg=foo&ListArgLocation.1=a&ListArgLocation.2=b&ListArgLocation.3=c"
}
}
]
},
{
"description": "Serialize map type",
"metadata": {
Expand Down

0 comments on commit 0db6dcd

Please sign in to comment.