[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/twilio-php/tests/resources/ -> MembersTest.php (source)

   1  <?php
   2  
   3  use \Mockery as m;
   4  
   5  class MembersTest extends PHPUnit_Framework_TestCase {
   6  
   7      protected $formHeaders = array('Content-Type' => 'application/x-www-form-urlencoded');
   8  
   9      function testFront() {
  10          $http = m::mock(new Services_Twilio_TinyHttp);
  11          $http->shouldReceive('get')->once()
  12              ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members/Front.json')
  13              ->andReturn(array(200, array('Content-Type' => 'application/json'),
  14                  json_encode(array('call_sid' => 'CA123', 'position' => 0))
  15              ));
  16          $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
  17          $queue = $client->account->queues->get('QQ123');
  18          $firstMember = $queue->members->front();
  19          $this->assertSame($firstMember->call_sid, 'CA123');
  20      }
  21  
  22      function testDequeueFront() {
  23          $http = m::mock(new Services_Twilio_TinyHttp);
  24          $http->shouldReceive('post')->once()
  25              ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members/Front.json',
  26                  $this->formHeaders, 'Url=http%3A%2F%2Ffoo.com&Method=POST')
  27              ->andReturn(array(200, array('Content-Type' => 'application/json'),
  28                  json_encode(array('call_sid' => 'CA123', 'position' => 0))
  29              ));
  30          $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
  31          $queue = $client->account->queues->get('QQ123');
  32          $firstMember = $queue->members->front();
  33          $firstMember->dequeue('http://foo.com');
  34      }
  35  
  36      function testDequeueSid() {
  37          $http = m::mock(new Services_Twilio_TinyHttp);
  38          $http->shouldReceive('post')->once()
  39              ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members/CA123.json',
  40                  $this->formHeaders, 'Url=http%3A%2F%2Ffoo.com&Method=GET')
  41              ->andReturn(array(200, array('Content-Type' => 'application/json'),
  42                  json_encode(array('call_sid' => 'CA123', 'position' => 0))
  43              ));
  44          $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
  45          $queue = $client->account->queues->get('QQ123');
  46          $firstMember = $queue->members->get('CA123');
  47          $firstMember->dequeue('http://foo.com', 'GET');
  48      }
  49  
  50      function testMemberIterate() {
  51          $http = m::mock(new Services_Twilio_TinyHttp);
  52          $resp = json_encode(
  53                      array(
  54                          'queue_members' => array(
  55                              array('call_sid' => 'CA123', 'wait_time' => 30)
  56                          ),
  57                          'end' => 1,
  58                      )
  59                  );
  60          $http->shouldReceive('get')->once()
  61              ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members.json?Page=0&PageSize=50')
  62              ->andReturn(array(200, array('Content-Type' => 'application/json'), $resp
  63              ));
  64          $http->shouldReceive('get')->once()
  65              ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members.json?Page=1&PageSize=50')
  66              ->andReturn(array(400, array('Content-Type' => 'application/json'),
  67                  '{"status":400,"message":"foo", "code": "20006"}'
  68              ));
  69          $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
  70          $queue = $client->account->queues->get('QQ123');
  71          foreach($queue->members as $member) {
  72              $this->assertSame($member->call_sid, 'CA123');
  73              $this->assertSame($member->wait_time, 30);
  74          }
  75      }
  76  
  77      function tearDown() {
  78          m::close();
  79      }
  80  
  81  }
  82  
  83  


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1