[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  use \Mockery as m;
   4  
   5  class AvailablePhoneNumbersTest extends PHPUnit_Framework_TestCase {
   6      function testPartialApplication() {
   7          $http = m::mock(new Services_Twilio_TinyHttp);
   8          $http->shouldReceive('get')->once()
   9              ->with('/2010-04-01/Accounts/AC123/AvailablePhoneNumbers/US/Local.json?AreaCode=510')
  10              ->andReturn(array(200, array('Content-Type' => 'application/json'),
  11                  json_encode(array('available_phone_numbers' => array(
  12                      'friendly_name' => '(510) 564-7903'
  13                  )))
  14              ));
  15          $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
  16          $nums = $client->account->available_phone_numbers->getLocal('US');
  17          $numsList = $nums->getList(array('AreaCode' => '510'));
  18          foreach ($numsList as $num) {
  19              $this->assertEquals('(510) 564-7903', $num->friendly_name);
  20          }
  21      }
  22  
  23      function testPagePhoneNumberResource() {
  24          $http = m::mock(new Services_Twilio_TinyHttp);
  25          $http->shouldReceive('get')->once()
  26              ->with('/2010-04-01/Accounts/AC123/AvailablePhoneNumbers.json?Page=0&PageSize=50')
  27              ->andReturn(array(200, array('Content-Type' => 'application/json'),
  28                  json_encode(array(
  29                      'total' => 1,
  30                      'countries' => array(array('country_code' => 'CA'))
  31                  ))
  32              ));
  33          $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
  34          $page = $client->account->available_phone_numbers->getPage('0');
  35          $this->assertEquals('CA', $page->countries[0]->country_code);
  36      }
  37  
  38      function testGetMobile() {
  39          $http = m::mock(new Services_Twilio_TinyHttp);
  40          $http->shouldReceive('get')->once()
  41              ->with('/2010-04-01/Accounts/AC123/AvailablePhoneNumbers/GB/Mobile.json')
  42              ->andReturn(array(200, array('Content-Type' => 'application/json'),
  43                  json_encode(array('available_phone_numbers' => array(
  44                      'friendly_name' => '(510) 564-7903'
  45                  )))
  46              ));
  47          $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
  48          $nums = $client->account->available_phone_numbers->getMobile('GB')->getList();
  49          foreach ($nums as $num) {
  50              $this->assertEquals('(510) 564-7903', $num->friendly_name);
  51          }
  52      }
  53  
  54      function tearDown() {
  55          m::close();
  56      }
  57  }


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