Permalink
Browse files

add failing conference mute test

  • Loading branch information...
1 parent 122a254 commit 52a6d8a3017e10bd6b792811bc0ad186151892f5 Kevin Burke committed Jul 23, 2012
Showing with 50 additions and 0 deletions.
  1. +50 −0 tests/ResourcesTest.php
@@ -245,6 +245,56 @@ function testBadMessageThrowsException() {
}
}
+class ConferencesTest extends PHPUnit_Framework_TestCase
+{
+ protected $formHeaders = array('Content-Type' => 'application/x-www-form-urlencoded');
+ function testMuteParticipant() {
+ $http = m::mock(new Services_Twilio_TinyHttp);
+ $http->shouldReceive('get')->once()
+ ->with('/2010-04-01/Accounts/AC123/Conferences.json?Page=0&PageSize=50&Status=in-progress')
+ ->andReturn(array(200, array('Content-Type' => 'application/json'),
+ json_encode(array('conferences' => array(array(
+ 'sid' => 'CF123'
+ ))
+ ))
+ ));
+ $http->shouldReceive('get')->once()
+ ->with('/2010-04-01/Accounts/AC123/Conferences/CF123/Participants.json?Page=0&PageSize=50')
+ ->andReturn(array(200, array('Content-Type' => 'application/json'),
+ json_encode(array('participants' => array(array(
+ 'call_sid' => 'CA345'
+ ))
+ ))
+ ));
+ /* Participants has no 'sid' parameter */
+ $http->shouldReceive('post')->once()
+ ->with('/2010-04-01/Accounts/AC123/Conferences/CF123/Participants/CA345.json',
+ $this->formHeaders, 'Muted=true')
+ ->andReturn(array(200, array('Content-Type' => 'application/json'),
+ json_encode(array('participants' => array(array(
+ 'call_sid' => 'CA345'
+ ))
+ ))
+ ));
+ $http->shouldReceive('get')->once()
+ ->with('/2010-04-01/Accounts/AC123/Conferences.json?Page=1&PageSize=50&Status=in-progress')
+ ->andReturn(array(400, array('Content-Type' => 'application/json'),
+ '{"status":400,"message":"foo", "code": "20006"}'
+ ));
+
+ $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
+ foreach($client->account->conferences->getIterator(0, 50, array('Status' => 'in-progress')) as $conference) {
+ $participants = $conference->participants->getPage(0, 50)->participants;
+ foreach ($participants as $p) {
+ $p->mute();
+ }
+ }
+ }
+
+ function tearDown() {
+ m::close();
+ }
+}
class CallsTest extends PHPUnit_Framework_TestCase
{

0 comments on commit 52a6d8a

Please sign in to comment.