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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
<?php
use \Mockery as m;
class IPMessagingChannelsTest extends PHPUnit_Framework_TestCase { protected $formHeaders = array('Content-Type' => 'application/x-www-form-urlencoded');
function testRead() { $http = m::mock(new Services_Twilio_TinyHttp); $http->shouldReceive('get')->once() ->with('/v1/Services/SV123/Channels?Page=0&PageSize=50') ->andReturn(array(200, array('Content-Type' => 'application/json'), json_encode(array( 'meta' => array('key' => 'channels', 'next_page_url' => null), 'channels' => array(array('sid' => 'CH123')) )) )); $ipMessagingClient = new IPMessaging_Services_Twilio('AC123', '123', 'v1', $http); $service = $ipMessagingClient->services->get('SV123'); foreach ($service->channels->getIterator(0, 50) as $channel) { $this->assertEquals('CH123', $channel->sid); } }
function testFetch() { $http = m::mock(new Services_Twilio_TinyHttp); $http->shouldReceive('get')->once() ->with('/v1/Services/SV123/Channels/CH123') ->andReturn(array(200, array('Content-Type' => 'application/json'), json_encode(array('sid' => 'CH123', 'friendly_name' => 'Channel')) )); $ipMessagingClient = new IPMessaging_Services_Twilio('AC123', '123', 'v1', $http); $service = $ipMessagingClient->services->get('SV123'); $channel = $service->channels->get('CH123'); $this->assertNotNull($channel); $this->assertEquals('Channel', $channel->friendly_name); }
function testCreate() { $http = m::mock(new Services_Twilio_TinyHttp); $http->shouldReceive('post')->once() ->with('/v1/Services/SV123/Channels', $this->formHeaders, 'FriendlyName=TestUrl') ->andReturn(array(200, array('Content-Type' => 'application/json'), json_encode(array('sid' => 'CH123')) )); $ipMessagingClient = new IPMessaging_Services_Twilio('AC123', '123', '2010-04-01', $http); $service = $ipMessagingClient->services->get('SV123'); $channel = $service->channels->create(array( 'FriendlyName' => 'TestUrl' )); $this->assertSame('CH123', $channel->sid); }
function testUpdate() { $http = m::mock(new Services_Twilio_TinyHttp); $http->shouldReceive('post')->once() ->with('/v1/Services/SV123/Channels/CH123', $this->formHeaders, 'FriendlyName=TestUrl') ->andReturn(array(200, array('Content-Type' => 'application/json'), json_encode(array('sid' => 'CH123')) )); $ipMessagingClient = new IPMessaging_Services_Twilio('AC123', '123', '2010-04-01', $http); $service = $ipMessagingClient->services->get('SV123'); $channel = $service->channels->get('CH123'); $channel->update(array( 'FriendlyName' => 'TestUrl' )); $this->assertSame('CH123', $channel->sid); }
function testDelete() { $http = m::mock(new Services_Twilio_TinyHttp); $http->shouldReceive('delete')->once() ->with('/v1/Services/SV123/Channels/CH123') ->andReturn(array(204, array('Content-Type' => 'application/json'), '' )); $ipMessagingClient = new IPMessaging_Services_Twilio('AC123', '123', null, $http); $service = $ipMessagingClient->services->get('SV123'); $service->channels->delete('CH123'); }
function tearDown() { m::close(); } }
|