public function testPerform()
{
$body = $this->prophesize('\\Psr\\Http\\Message\\StreamInterface');
$body->getContents()->shouldBeCalledTimes(1)->willReturn('ABC');
$response = $this->prophesize('\\Psr\\Http\\Message\\ResponseInterface');
$response->getBody()->shouldBeCalledTimes(1)->willReturn($body->reveal());
$client = $this->prophesize('\\GuzzleHttp\\ClientInterface');
$client->send(Argument::that(function ($request) {
if (!$request instanceof RequestInterface) {
return false;
}
$uri = $request->getUri();
$parts = [];
parse_str($uri->getQuery(), $parts);
$this->assertSame('webservices.amazon.de', $uri->getHost());
$this->assertSame('/onca/xml', $uri->getPath());
$this->assertArrayHasKey('AWSAccessKeyId', $parts);
$this->assertSame('jkl', $parts['AWSAccessKeyId']);
$this->assertArrayHasKey('AssociateTag', $parts);
$this->assertSame('def', $parts['AssociateTag']);
$this->assertArrayHasKey('ItemId', $parts);
$this->assertSame('1', $parts['ItemId']);
$this->assertArrayHasKey('Test', $parts);
$this->assertSame('a,b', $parts['Test']);
$this->assertArrayHasKey('Operation', $parts);
$this->assertSame('ItemLookup', $parts['Operation']);
$this->assertArrayHasKey('Service', $parts);
$this->assertSame('AWSECommerceService', $parts['Service']);
$this->assertArrayHasKey('Timestamp', $parts);
$this->assertRegExp('#[0-9]{4}(-[0-9]{2}){2}T([0-9]{2}:){2}[0-9]{2}Z#', $parts['Timestamp']);
$this->assertArrayHasKey('Version', $parts);
$this->assertSame('2013-08-01', $parts['Version']);
$this->assertArrayHasKey('Signature', $parts);
return true;
}))->shouldBeCalledTimes(1)->willReturn($response->reveal());
$request = new GuzzleRequest($client->reveal());
$operation = new Lookup();
$operation->setItemId('1');
$operation->setTest(['a', 'b']);
$config = new GenericConfiguration();
$config->setAccessKey('abc');
$config->setAssociateTag('def');
$config->setCountry('DE');
$config->setSecretKey('ghi');
$config->setAccessKey('jkl');
$request->perform($operation, $config);
}