Skip to content

Commit

Permalink
More test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Gauthier committed Jul 6, 2009
1 parent f0a7571 commit e2f012d
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 0 deletions.
100 changes: 100 additions & 0 deletions tests/ChangeMessageVisibilityTestCase.php
Expand Up @@ -192,6 +192,106 @@ public function testChangeMessageVisibilityInvalidMessage()
);
}

// }}}
// {{{ testChangeMessageVisibilityWithInvalidQueue()

/**
* @group messages
* @expectedException Services_Amazon_SQS_InvalidQueueException
*/
public function testChangeMessageVisibilityWithInvalidQueue()
{
// {{{ response body
$body = <<<XML
<?xml version="1.0"?>
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2009-02-01/">
<Error>
<Type>Sender</Type>
<Code>AWS.SimpleQueueService.NonExistentQueue</Code>
<Message>The specified queue does not exist for this wsdl version.</Message>
<Detail/>
</Error>
<RequestId>05714b4b-7359-4527-9bd1-c9aaacb4a2ad</RequestId>
</ErrorResponse>
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 = <<<XML
<?xml version="1.0"?>
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2009-02-01/">
<Error>
<Type>Receiver</Type>
<Code>InternalError</Code>
<Message>We encountered an internal error. Please try again.</Message>
<Detail/>
</Error>
<RequestId>d22acfe7-a4c3-4ab4-b0f3-3fbc20b97c1d</RequestId>
</ErrorResponse>
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
);
}

// }}}
}

Expand Down
51 changes: 51 additions & 0 deletions tests/DeleteMessageTestCase.php
Expand Up @@ -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 = <<<XML
<?xml version="1.0"?>
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2009-02-01/">
<Error>
<Type>Deleteer</Type>
<Code>AWS.SimpleQueueService.NonExistentQueue</Code>
<Message>The specified queue does not exist for this wsdl version.</Message>
<Detail/>
</Error>
<RequestId>05714b4b-7359-4527-9bd1-c9aaacb4a2ad</RequestId>
</ErrorResponse>
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'
);
}

// }}}
}

Expand Down
88 changes: 88 additions & 0 deletions tests/GetAttributesTestCase.php
Expand Up @@ -516,6 +516,94 @@ public function testGetMultiInvalidAttribute()
);
}

// }}}
// {{{ testGetAttributesWithInvalidQueue()

/**
* @group attributes
* @expectedException Services_Amazon_SQS_InvalidQueueException
*/
public function testGetAttributesWithInvalidQueue()
{
// {{{ response body
$body = <<<XML
<?xml version="1.0"?>
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2009-02-01/">
<Error>
<Type>Sender</Type>
<Code>AWS.SimpleQueueService.NonExistentQueue</Code>
<Message>The specified queue does not exist for this wsdl version.</Message>
<Detail/>
</Error>
<RequestId>05714b4b-7359-4527-9bd1-c9aaacb4a2ad</RequestId>
</ErrorResponse>
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 = <<<XML
<?xml version="1.0"?>
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2009-02-01/">
<Error>
<Type>Receiver</Type>
<Code>InternalError</Code>
<Message>We encountered an internal error. Please try again.</Message>
<Detail/>
</Error>
<RequestId>d22acfe7-a4c3-4ab4-b0f3-3fbc20b97c1d</RequestId>
</ErrorResponse>
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();
}

// }}}
}

Expand Down
42 changes: 42 additions & 0 deletions tests/SendMessageTestCase.php
Expand Up @@ -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 = <<<XML
<?xml version="1.0"?>
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2009-02-01/">
<Error>
<Type>Receiver</Type>
<Code>InternalError</Code>
<Message>We encountered an internal error. Please try again.</Message>
<Detail/>
</Error>
<RequestId>d22acfe7-a4c3-4ab4-b0f3-3fbc20b97c1d</RequestId>
</ErrorResponse>
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');
}

// }}}
}

Expand Down

0 comments on commit e2f012d

Please sign in to comment.