/tests/CallTest.php

http://github.com/mheadd/tropo-webapi-php · PHP · 66 lines · 59 code · 7 blank · 0 comment · 0 complexity · 9aa0c2e63cf6e49023ed6904e677def6 MD5 · raw file

  1. <?php
  2. require_once 'PHPUnit/Framework.php';
  3. require_once 'tropo.class.php';
  4. class CallTest extends PHPUnit_Framework_TestCase
  5. {
  6. public function testToOnly()
  7. {
  8. $tropo = new Tropo();
  9. $tropo->call("3055195825");
  10. $this->assertEquals('{"tropo":[{"call":{"to":"3055195825"}}]}', sprintf($tropo));
  11. }
  12. public function testUseAllOptions()
  13. {
  14. $tropo = new Tropo();
  15. $rec = new StartRecording('recording','audio/mp3','POST','password','http://blah.com/recordings/1234.wav','jose');
  16. $options = array(
  17. 'from' => "3055551212",
  18. 'network' => "SMS",
  19. 'channel' => "TEXT",
  20. 'answerOnMedia' => false,
  21. 'timeout' => 10,
  22. 'headers' => array('foo'=>'bar','bling'=>'baz'),
  23. 'recording' => $rec
  24. );
  25. $tropo->call("3055195825",$options);
  26. $this->assertEquals('{"tropo":[{"call":{"to":"3055195825","from":"3055551212","network":"SMS","channel":"TEXT","timeout":10,"answerOnMedia":false,"headers":{"foo":"bar","bling":"baz"},"recording":{"format":"audio/mp3","method":"POST","password":"password","url":"http://blah.com/recordings/1234.wav","username":"jose"}}}]}', sprintf($tropo));
  27. }
  28. public function testUseDifferentOptionsOrder()
  29. {
  30. $tropo = new Tropo();
  31. $rec = new StartRecording('recording','audio/mp3','POST','password','http://blah.com/recordings/1234.wav','jose');
  32. $options = array(
  33. 'answerOnMedia' => false,
  34. 'timeout' => 10,
  35. 'network' => "SMS",
  36. 'channel' => "TEXT",
  37. 'headers' => array('foo'=>'bar','bling'=>'baz'),
  38. 'recording' => $rec,
  39. 'from' => "3055551212"
  40. );
  41. $tropo->call("3055195825",$options);
  42. $this->assertEquals('{"tropo":[{"call":{"to":"3055195825","from":"3055551212","network":"SMS","channel":"TEXT","timeout":10,"answerOnMedia":false,"headers":{"foo":"bar","bling":"baz"},"recording":{"format":"audio/mp3","method":"POST","password":"password","url":"http://blah.com/recordings/1234.wav","username":"jose"}}}]}', sprintf($tropo));
  43. }
  44. public function testCreateCallObject()
  45. {
  46. $rec = new StartRecording('recording','audio/mp3','POST','password','http://blah.com/recordings/1234.wav','jose');
  47. $call = new Call("3055195825","3055551212","SMS","TEXT",false,10,array('foo'=>'bar','bling'=>'baz'),$rec);
  48. $this->assertEquals('{"to":"3055195825","from":"3055551212","network":"SMS","channel":"TEXT","timeout":10,"answerOnMedia":false,"headers":{"foo":"bar","bling":"baz"},"recording":{"format":"audio/mp3","method":"POST","password":"password","url":"http://blah.com/recordings/1234.wav","username":"jose"}}', sprintf($call));
  49. }
  50. public function testCallUsingCallObject()
  51. {
  52. $tropo = new Tropo();
  53. $rec = new StartRecording('recording','audio/mp3','POST','password','http://blah.com/recordings/1234.wav','jose');
  54. $call = new Call("3055195825","3055551212","SMS","TEXT",false,10,array('foo'=>'bar','bling'=>'baz'),$rec);
  55. $tropo->call($call);
  56. $this->assertEquals('{"tropo":[{"call":{"to":"3055195825","from":"3055551212","network":"SMS","channel":"TEXT","timeout":10,"answerOnMedia":false,"headers":{"foo":"bar","bling":"baz"},"recording":{"format":"audio/mp3","method":"POST","password":"password","url":"http://blah.com/recordings/1234.wav","username":"jose"}}}]}', sprintf($tropo));
  57. }
  58. }
  59. ?>