1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?php
use \Mockery as m; require_once 'Twilio.php';
class PhoneNumberTest extends PHPUnit_Framework_TestCase {
function testGetCountries() { $data = array( 'meta' => array( 'key' => 'countries', 'next_page_url' => null ), 'countries' => array( array('iso_country' => 'US') ) ); $http = m::mock(new Services_Twilio_TinyHttp); $http->shouldReceive('get')->once()->with( '/v1/PhoneNumbers/Countries?Page=0&PageSize=50' )->andReturn(array(200, array('Content-Type' => 'application/json'), json_encode($data)));
$pricingClient = new Pricing_Services_Twilio('AC123', '123', 'v1', $http, 1); $countries = $pricingClient->phoneNumberCountries->getPage(); $this->assertNotNull($countries);
$countryList = $countries->getItems(); $country = $countryList[0]; $this->assertNotNull($country); $this->assertEquals($country->iso_country, 'US'); }
function testGetCountry() { $http = m::mock(new Services_Twilio_TinyHttp); $http->shouldReceive('get')->once()->with('/v1/PhoneNumbers/Countries/EE') ->andReturn(array(200, array('Content-Type' => 'application/json'), json_encode(array('country' => 'Estonia')))); $pricingClient = new Pricing_Services_Twilio('AC123', '123', 'v1', $http, 1);
$country = $pricingClient->phoneNumberCountries->get('EE'); $this->assertNotNull($country); $this->assertEquals($country->iso_country, 'EE'); $this->assertEquals($country->country, 'Estonia'); } }
|