Permalink
Browse files

Add tests for new Queue behavior.

  • Loading branch information...
Kevin Burke
Kevin Burke committed Aug 4, 2012
1 parent 27b6ca7 commit ff6ad932b60374aebb9f6c1686e880594d2ce707
Showing with 55 additions and 1 deletion.
  1. +55 −1 tests/ResourcesTest.php
View
@@ -267,7 +267,9 @@ function sidProvider()
}
}
-class QueuesTest extends PHPUnit_Framework_TestCase {
+class MembersTest extends PHPUnit_Framework_TestCase {
+
+ protected $formHeaders = array('Content-Type' => 'application/x-www-form-urlencoded');
function testFront() {
$http = m::mock(new Services_Twilio_TinyHttp);
@@ -282,8 +284,60 @@ function testFront() {
$this->assertSame($firstMember->call_sid, 'CA123');
}
+ function testDequeueFront() {
+ $http = m::mock(new Services_Twilio_TinyHttp);
+ $http->shouldReceive('post')->once()
+ ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members/Front.json',
+ $this->formHeaders, 'Url=http%3A%2F%2Ffoo.com&Method=POST')
+ ->andReturn(array(200, array('Content-Type' => 'application/json'),
+ json_encode(array('call_sid' => 'CA123', 'position' => 0))
+ ));
+ $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
+ $queue = $client->account->queues->get('QQ123');
+ $firstMember = $queue->members->front();
+ $firstMember->dequeue('http://foo.com');
+ }
+
+ function testDequeueSid() {
+ $http = m::mock(new Services_Twilio_TinyHttp);
+ $http->shouldReceive('post')->once()
+ ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members/CA123.json',
+ $this->formHeaders, 'Url=http%3A%2F%2Ffoo.com&Method=GET')
+ ->andReturn(array(200, array('Content-Type' => 'application/json'),
+ json_encode(array('call_sid' => 'CA123', 'position' => 0))
+ ));
+ $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
+ $queue = $client->account->queues->get('QQ123');
+ $firstMember = $queue->members->get('CA123');
+ $firstMember->dequeue('http://foo.com', 'GET');
+ }
+
function tearDown() {
m::close();
}
}
+
+class QueuesTest extends PHPUnit_Framework_TestCase {
+
+ protected $formHeaders = array('Content-Type' => 'application/x-www-form-urlencoded');
+
+ function testCreate() {
+ $http = m::mock(new Services_Twilio_TinyHttp);
+ $http->shouldReceive('post')->once()
+ ->with('/2010-04-01/Accounts/AC123/Queues.json', $this->formHeaders,
+ 'FriendlyName=foo&MaxSize=123')
+ ->andReturn(array(200, array('Content-Type' => 'application/json'),
+ json_encode(array('sid' => 'QQ123', 'average_wait_time' => 0))
+ ));
+ $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
+ $queue = $client->account->queues->create('foo',
+ array('MaxSize' => 123));
+ $this->assertSame($queue->sid, 'QQ123');
+ $this->assertSame($queue->average_wait_time, 0);
+ }
+
+ function tearDown() {
+ m::close();
+ }
+}

0 comments on commit ff6ad93

Please sign in to comment.