From e2f012d1e8fd85acfb6b0f2531f233890cefa89f Mon Sep 17 00:00:00 2001 From: Michael Gauthier Date: Mon, 6 Jul 2009 20:46:11 +0000 Subject: [PATCH] More test coverage. git-svn-id: https://svn.php.net/repository/pear/packages/Services_Amazon_SQS/trunk@283601 c90b9560-bf6c-de11-be94-00142212c4b1 --- tests/ChangeMessageVisibilityTestCase.php | 100 ++++++++++++++++++++++ tests/DeleteMessageTestCase.php | 51 +++++++++++ tests/GetAttributesTestCase.php | 88 +++++++++++++++++++ tests/SendMessageTestCase.php | 42 +++++++++ 4 files changed, 281 insertions(+) diff --git a/tests/ChangeMessageVisibilityTestCase.php b/tests/ChangeMessageVisibilityTestCase.php index 7e5290f..f05890e 100644 --- a/tests/ChangeMessageVisibilityTestCase.php +++ b/tests/ChangeMessageVisibilityTestCase.php @@ -192,6 +192,106 @@ public function testChangeMessageVisibilityInvalidMessage() ); } + // }}} + // {{{ testChangeMessageVisibilityWithInvalidQueue() + + /** + * @group messages + * @expectedException Services_Amazon_SQS_InvalidQueueException + */ + public function testChangeMessageVisibilityWithInvalidQueue() + { + // {{{ response body + $body = << + + + Sender + AWS.SimpleQueueService.NonExistentQueue + The specified queue does not exist for this wsdl version. + + + 05714b4b-7359-4527-9bd1-c9aaacb4a2ad + +XML; + + $body = $this->formatXml($body); + // }}} + // {{{ response headers + $headers = array( + 'Content-Type' => 'text/xml', + 'Transfer-Encoding' => 'chunked', + 'Date' => 'Sun, 18 Jan 2009 17:34:20 GMT', + 'Cneonction' => 'close', // Intentional misspelling + 'Server' => 'AWS Simple Queue Service' + ); + // }}} + $this->addHttpResponse($body, $headers, 'HTTP/1.1 400 Bad Request'); + + $queue = new Services_Amazon_SQS_Queue( + 'http://queue.amazonaws.com/this-queue-does-not-exist', + '123456789ABCDEFGHIJK', + 'abcdefghijklmnopqrstuzwxyz/ABCDEFGHIJKLM', + $this->request + ); + + $queue->changeMessageVisibility( + '+eXJYhj5rDqRunVNVvjOQKJ0obJP08UNsXdn2v3Lwq+' . + 'TDtD3hk3aBKbSH1mGc4hzO/VZOIC0RFzLWMLhfKh4qn' . + 'n3x35CTz9dLTiBp6rMQSSsfakSe+GcTkPfqzNJdCM4P' . + 'zHuhDaS9mXjcAcCzIRrOX9Mp5AiZxsfiLGqOsqhtH0', + 3600 + ); + } + + // }}} + // {{{ testChangeMessageVisibilityWithUnknownError() + + /** + * @group message + * @expectedException Services_Amazon_SQS_ErrorException + */ + public function testChangeMessageVisibilityWithUnknownError() + { + // {{{ response body + $body = << + + + Receiver + InternalError + We encountered an internal error. Please try again. + + + d22acfe7-a4c3-4ab4-b0f3-3fbc20b97c1d + +XML; + + $body = $this->formatXml($body); + // }}} + // {{{ response headers + $headers = array( + 'Transfer-Encoding' => 'chunked', + 'Date' => 'Sun, 18 Jan 2009 17:34:20 GMT', + 'Cneonction' => 'close', // Intentional misspelling + 'Server' => 'AWS Simple Queue Service' + ); + // }}} + $this->addHttpResponse( + $body, + $headers, + 'HTTP/1.1 500 Internal Server Error' + ); + + $this->queue->changeMessageVisibility( + '+eXJYhj5rDqRunVNVvjOQKJ0obJP08UNsXdn2v3Lwq+' . + 'TDtD3hk3aBKbSH1mGc4hzO/VZOIC0RFzLWMLhfKh4qn' . + 'n3x35CTz9dLTiBp6rMQSSsfakSe+GcTkPfqzNJdCM4P' . + 'zHuhDaS9mXjcAcCzIRrOX9Mp5AiZxsfiLGqOsqhtH0', + 3600 + ); + } + // }}} } diff --git a/tests/DeleteMessageTestCase.php b/tests/DeleteMessageTestCase.php index 29009bc..9ee0e85 100644 --- a/tests/DeleteMessageTestCase.php +++ b/tests/DeleteMessageTestCase.php @@ -143,6 +143,57 @@ public function testDeleteInvalidMessage() $this->queue->delete('invalid-receipt-handle'); } + // }}} + // {{{ testDeleteMessageInvalidQueue() + + /** + * @group message + * @expectedException Services_Amazon_SQS_InvalidQueueException + */ + public function testDeleteMessageInvalidQueue() + { + // {{{ response body + $body = << + + + Deleteer + AWS.SimpleQueueService.NonExistentQueue + The specified queue does not exist for this wsdl version. + + + 05714b4b-7359-4527-9bd1-c9aaacb4a2ad + +XML; + + $body = $this->formatXml($body); + // }}} + // {{{ response headers + $headers = array( + 'Content-Type' => 'text/xml', + 'Transfer-Encoding' => 'chunked', + 'Date' => 'Sun, 18 Jan 2009 17:34:20 GMT', + 'Cneonction' => 'close', // Intentional misspelling + 'Server' => 'AWS Simple Queue Service' + ); + // }}} + $this->addHttpResponse($body, $headers, 'HTTP/1.1 400 Bad Request'); + + $queue = new Services_Amazon_SQS_Queue( + 'http://queue.amazonaws.com/this-queue-does-not-exist', + '123456789ABCDEFGHIJK', + 'abcdefghijklmnopqrstuzwxyz/ABCDEFGHIJKLM', + $this->request + ); + + $queue->delete( + '+eXJYhj5rDqRunVNVvjOQKJ0obJP08UNsXdn2v3Lwq+' . + 'TDtD3hk3aBKbSH1mGc4hzO/VZOIC0RFzLWMLhfKh4qn' . + 'n3x35CTz9dLTiBp6rMQSSsfakSe+GcTkPfqzNJdCM4P' . + 'zHuhDaS9mXjcAcCzIRrOX9Mp5AiZxsfiLGqOsqhtH0' + ); + } + // }}} } diff --git a/tests/GetAttributesTestCase.php b/tests/GetAttributesTestCase.php index dee8c00..62a9c8f 100644 --- a/tests/GetAttributesTestCase.php +++ b/tests/GetAttributesTestCase.php @@ -516,6 +516,94 @@ public function testGetMultiInvalidAttribute() ); } + // }}} + // {{{ testGetAttributesWithInvalidQueue() + + /** + * @group attributes + * @expectedException Services_Amazon_SQS_InvalidQueueException + */ + public function testGetAttributesWithInvalidQueue() + { + // {{{ response body + $body = << + + + Sender + AWS.SimpleQueueService.NonExistentQueue + The specified queue does not exist for this wsdl version. + + + 05714b4b-7359-4527-9bd1-c9aaacb4a2ad + +XML; + + $body = $this->formatXml($body); + // }}} + // {{{ response headers + $headers = array( + 'Content-Type' => 'text/xml', + 'Transfer-Encoding' => 'chunked', + 'Date' => 'Sun, 18 Jan 2009 17:34:20 GMT', + 'Cneonction' => 'close', // Intentional misspelling + 'Server' => 'AWS Simple Queue Service' + ); + // }}} + $this->addHttpResponse($body, $headers, 'HTTP/1.1 400 Bad Request'); + + $queue = new Services_Amazon_SQS_Queue( + 'http://queue.amazonaws.com/this-queue-does-not-exist', + '123456789ABCDEFGHIJK', + 'abcdefghijklmnopqrstuzwxyz/ABCDEFGHIJKLM', + $this->request + ); + + $attributes = $queue->getAttributes(); + } + + // }}} + // {{{ testGetAttributesWithUnknownError() + + /** + * @group attributes + * @expectedException Services_Amazon_SQS_ErrorException + */ + public function testGetAttributesWithUnknownError() + { + // {{{ response body + $body = << + + + Receiver + InternalError + We encountered an internal error. Please try again. + + + d22acfe7-a4c3-4ab4-b0f3-3fbc20b97c1d + +XML; + + $body = $this->formatXml($body); + // }}} + // {{{ response headers + $headers = array( + 'Transfer-Encoding' => 'chunked', + 'Date' => 'Sun, 18 Jan 2009 17:34:20 GMT', + 'Cneonction' => 'close', // Intentional misspelling + 'Server' => 'AWS Simple Queue Service' + ); + // }}} + $this->addHttpResponse( + $body, + $headers, + 'HTTP/1.1 500 Internal Server Error' + ); + + $attributes = $this->queue->getAttributes(); + } + // }}} } diff --git a/tests/SendMessageTestCase.php b/tests/SendMessageTestCase.php index 047e30f..76586c8 100644 --- a/tests/SendMessageTestCase.php +++ b/tests/SendMessageTestCase.php @@ -406,6 +406,48 @@ public function testSendMessageInvalidChecksum() $messageId = $this->queue->send('Services_Amazon_SQS Unit Test'); } + // }}} + // {{{ testSendMessageWithUnknownError() + + /** + * @group message + * @expectedException Services_Amazon_SQS_ErrorException + */ + public function testSendMessageWithUnknownError() + { + // {{{ response body + $body = << + + + Receiver + InternalError + We encountered an internal error. Please try again. + + + d22acfe7-a4c3-4ab4-b0f3-3fbc20b97c1d + +XML; + + $body = $this->formatXml($body); + // }}} + // {{{ response headers + $headers = array( + 'Transfer-Encoding' => 'chunked', + 'Date' => 'Sun, 18 Jan 2009 17:34:20 GMT', + 'Cneonction' => 'close', // Intentional misspelling + 'Server' => 'AWS Simple Queue Service' + ); + // }}} + $this->addHttpResponse( + $body, + $headers, + 'HTTP/1.1 500 Internal Server Error' + ); + + $this->queue->send('Test Message'); + } + // }}} }