1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-15 18:10:53 +01:00
phorge-phorge/externals/twilio-php/tests/resources/ConnectAppsTest.php
Bob Trahan e96c363eef Add SMS support
Summary:
Provides a working SMS implementation with support for Twilio.

This version doesn't really retry if we get any gruff at all. Future versions should retry.

Test Plan: used bin/sms to send messages and look at them.

Reviewers: chad, epriestley

Reviewed By: epriestley

Subscribers: aurelijus, epriestley, Korvin

Maniphest Tasks: T920

Differential Revision: https://secure.phabricator.com/D8930
2014-05-09 12:47:21 -07:00

54 lines
2.2 KiB
PHP
Executable file

<?php
use \Mockery as m;
class ConnectAppsTest extends PHPUnit_Framework_TestCase {
function testUpdateWithArray() {
$http = m::mock(new Services_Twilio_TinyHttp);
$http->shouldReceive('get')->once()
->with('/2010-04-01/Accounts/AC123/ConnectApps/CN123.json')
->andReturn(array(200, array('Content-Type' => 'application/json'),
json_encode(array('friendly_name' => 'foo'))
));
$http->shouldReceive('post')->once()
->with('/2010-04-01/Accounts/AC123/ConnectApps/CN123.json',
array('Content-Type' => 'application/x-www-form-urlencoded'),
'FriendlyName=Bar')
->andReturn(array(200, array('Content-Type' => 'application/json'),
json_encode(array('friendly_name' => 'Bar'))
));
$client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
$cn = $client->account->connect_apps->get('CN123');
$this->assertEquals('foo', $cn->friendly_name);
$cn->update(array('FriendlyName' => 'Bar'));
$this->assertEquals('Bar', $cn->friendly_name);
}
function testUpdateWithOneParam()
{
$http = m::mock(new Services_Twilio_TinyHttp);
$http->shouldReceive('get')->once()
->with('/2010-04-01/Accounts/AC123/ConnectApps/CN123.json')
->andReturn(array(200, array('Content-Type' => 'application/json'),
json_encode(array('friendly_name' => 'foo'))
));
$http->shouldReceive('post')->once()
->with('/2010-04-01/Accounts/AC123/ConnectApps/CN123.json',
array('Content-Type' => 'application/x-www-form-urlencoded'),
'FriendlyName=Bar')
->andReturn(array(200, array('Content-Type' => 'application/json'),
json_encode(array('friendly_name' => 'Bar'))
));
$client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
$cn = $client->account->connect_apps->get('CN123');
$this->assertEquals('foo', $cn->friendly_name);
$cn->update('FriendlyName', 'Bar');
$this->assertEquals('Bar', $cn->friendly_name);
}
function tearDown()
{
m::close();
}
}