PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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