PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/aws/aws-sdk-php/tests/Aws/Tests/Sqs/SqsClientTest.php

https://github.com/lslucas/105fm
PHP | 76 lines | 48 code | 7 blank | 21 comment | 0 complexity | ac329654c1362b5c22f7f596862a2794 MD5 | raw file
  1. <?php
  2. /**
  3. * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License").
  6. * You may not use this file except in compliance with the License.
  7. * A copy of the License is located at
  8. *
  9. * http://aws.amazon.com/apache2.0
  10. *
  11. * or in the "license" file accompanying this file. This file is distributed
  12. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  13. * express or implied. See the License for the specific language governing
  14. * permissions and limitations under the License.
  15. */
  16. namespace Aws\Tests\Sqs;
  17. use Aws\Sqs\SqsClient;
  18. use Guzzle\Http\Message\Response;
  19. use Guzzle\Plugin\Mock\MockPlugin;
  20. class SqsClientTest extends \Guzzle\Tests\GuzzleTestCase
  21. {
  22. /**
  23. * @covers Aws\Sqs\SqsClient::factory
  24. */
  25. public function testFactoryInitializesClient()
  26. {
  27. $client = SqsClient::factory(array(
  28. 'key' => 'foo',
  29. 'secret' => 'bar',
  30. 'region' => 'us-east-1'
  31. ));
  32. $this->assertInstanceOf('Aws\Common\Signature\SignatureV4', $client->getSignature());
  33. $this->assertInstanceOf('Aws\Common\Credentials\Credentials', $client->getCredentials());
  34. $this->assertEquals('https://sqs.us-east-1.amazonaws.com', $client->getBaseUrl());
  35. }
  36. public function testGetQueueArn()
  37. {
  38. $url = 'https://sqs.us-east-1.amazonaws.com/057737625318/php-integ-sqs-queue-1359765974';
  39. $arn = 'arn:aws:sqs:us-east-1:057737625318:php-integ-sqs-queue-1359765974';
  40. $sqs = SqsClient::factory(array('region' => 'us-east-1'));
  41. $this->assertEquals($arn, $sqs->getQueueArn($url));
  42. }
  43. /**
  44. * @expectedException \Aws\Sqs\Exception\SqsException
  45. * @expectedExceptionMessage Body MD5 mismatch for
  46. */
  47. public function testValidatesSuccessfulMd5OfBody()
  48. {
  49. $mock = new MockPlugin(array(
  50. Response::fromMessage("HTTP/1.1 200 OK\r\nContent-Type: application/xml\r\n\r\n" .
  51. "<ReceiveMessageResponse>
  52. <ReceiveMessageResult>
  53. <Message>
  54. <MD5OfBody>fooo</MD5OfBody>
  55. <Body>This is a test message</Body>
  56. </Message>
  57. </ReceiveMessageResult>
  58. </ReceiveMessageResponse>"
  59. )
  60. ));
  61. $sqs = SqsClient::factory(array(
  62. 'key' => 'abc',
  63. 'secret' => '123',
  64. 'region' => 'us-east-1'
  65. ));
  66. $sqs->addSubscriber($mock);
  67. $sqs->receiveMessage(array('QueueUrl' => 'http://foo.com'));
  68. }
  69. }