forked from mheadd/tropo-webapi-php-original
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
132 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,22 @@ public function testMessageWithMinOptions() { | |
$this->assertEquals(sprintf($tropo), '{"tropo":[{"message":{"say":{"value":"This is an announcement."},"to":"sip:[email protected]:5678"}}]}'); | ||
} | ||
|
||
public function testMessageWithMMS() { | ||
$tropo = new Tropo(); | ||
$say = new Say("This is the subject",null, null, null, null, null,null,null,"http://user:[email protected]/1.jpg"); | ||
$message = new Message($say,'sip:[email protected]:5678',null, Network::$mms); | ||
$tropo->message($message); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"message":{"say":{"value":"This is the subject","media":"http://user:[email protected]/1.jpg"},"to":"sip:[email protected]:5678","network":"MMS"}}]}'); | ||
} | ||
|
||
public function testMessageWithMMS1() { | ||
$tropo = new Tropo(); | ||
$say = new Say("This is the subject",null, null, null, null, null,null,null,array("http://server.com/1.jpg", "this is a inline text content", "http://filehosting.tropo.com/account/1/2.text")); | ||
$message = new Message($say,'sip:[email protected]:5678',null, Network::$mms); | ||
$tropo->message($message); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"message":{"say":{"value":"This is the subject","media":["http://server.com/1.jpg","this is a inline text content","http://filehosting.tropo.com/account/1/2.text"]},"to":"sip:[email protected]:5678","network":"MMS"}}]}'); | ||
} | ||
|
||
public function testMessageWithExtraSayOptiions() { | ||
$tropo = new Tropo(); | ||
$say = "Remember, you have a meeting at 2 PM."; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,18 @@ public function testSayWithOptions() { | |
$this->assertEquals(sprintf($tropo), '{"tropo":[{"say":[{"value":"Please enter your account number...","name":"say"}]}]}'); | ||
} | ||
|
||
public function testSayWithOptions1() { | ||
$tropo = new Tropo(); | ||
$tropo->say("Please enter your account number...",array('name' => 'say','media' => 'http://user:[email protected]/1.jpg')); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"say":[{"value":"Please enter your account number...","name":"say","media":"http://user:[email protected]/1.jpg"}]}]}'); | ||
} | ||
|
||
public function testSayWithOptions2() { | ||
$tropo = new Tropo(); | ||
$tropo->say("Please enter your account number...",array('name' => 'say','media' => array('http://server.com/1.jpg', 'this is a inline text content', 'http://filehosting.tropo.com/account/1/2.text'))); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"say":[{"value":"Please enter your account number...","name":"say","media":["http://server.com/1.jpg","this is a inline text content","http://filehosting.tropo.com/account/1/2.text"]}]}]}'); | ||
} | ||
|
||
public function testCreateSayObject() | ||
{ | ||
$tropo = new Tropo(); | ||
|
@@ -40,6 +52,56 @@ public function testCreateSayObject1() | |
$this->assertEquals(sprintf($tropo), '{"tropo":[{"say":[{"value":"Please enter your account number...","as":"DATE","voice":"allison","allowSignals":["exit","quit"],"required":true,"promptLogSecurity":"suppress"}]}]}'); | ||
} | ||
|
||
public function testCreateSayObject2() | ||
{ | ||
$tropo = new Tropo(); | ||
$allowSignals = array('exit','quit'); | ||
$say = new Say("Please enter your account number...", SayAs::$date, null, Voice::$US_English_female_allison, $allowSignals, null, true, "suppress", "http://user:[email protected]/1.jpg"); | ||
$tropo->say($say); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"say":[{"value":"Please enter your account number...","as":"DATE","voice":"allison","allowSignals":["exit","quit"],"required":true,"promptLogSecurity":"suppress","media":"http://user:[email protected]/1.jpg"}]}]}'); | ||
} | ||
|
||
public function testCreateSayObject3() | ||
{ | ||
$tropo = new Tropo(); | ||
$allowSignals = array('exit','quit'); | ||
$say = new Say("Please enter your account number...", SayAs::$date, null, Voice::$US_English_female_allison, $allowSignals, null, true, "suppress", array('http://server.com/1.jpg', 'this is a inline text content', 'http://filehosting.tropo.com/account/1/2.text')); | ||
$tropo->say($say); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"say":[{"value":"Please enter your account number...","as":"DATE","voice":"allison","allowSignals":["exit","quit"],"required":true,"promptLogSecurity":"suppress","media":["http://server.com/1.jpg","this is a inline text content","http://filehosting.tropo.com/account/1/2.text"]}]}]}'); | ||
} | ||
|
||
public function testCreateSayObject4() | ||
{ | ||
$tropo = new Tropo(); | ||
$allowSignals = array('exit','quit'); | ||
$params = array( | ||
"as"=>SayAs::$date, | ||
"event"=>"event", | ||
"voice"=>Voice::$US_English_female_allison, | ||
"allowSignals"=>$allowSignals, | ||
"promptLogSecurity"=>"suppress", | ||
"required"=>true, | ||
"media"=>"http://user:[email protected]/1.jpg"); | ||
$tropo->say("Please enter your account number...",$params); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"say":[{"value":"Please enter your account number...","as":"DATE","voice":"allison","allowSignals":["exit","quit"],"required":true,"promptLogSecurity":"suppress","media":"http://user:[email protected]/1.jpg"}]}]}'); | ||
} | ||
|
||
public function testCreateSayObject5() | ||
{ | ||
$tropo = new Tropo(); | ||
$allowSignals = array('exit','quit'); | ||
$params = array( | ||
"as"=>SayAs::$date, | ||
"event"=>"event", | ||
"voice"=>Voice::$US_English_female_allison, | ||
"allowSignals"=>$allowSignals, | ||
"promptLogSecurity"=>"suppress", | ||
"required"=>true, | ||
"media"=>array('http://server.com/1.jpg', 'this is a inline text content', 'http://filehosting.tropo.com/account/1/2.text')); | ||
$tropo->say("Please enter your account number...",$params); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"say":[{"value":"Please enter your account number...","as":"DATE","voice":"allison","allowSignals":["exit","quit"],"required":true,"promptLogSecurity":"suppress","media":["http://server.com/1.jpg","this is a inline text content","http://filehosting.tropo.com/account/1/2.text"]}]}]}'); | ||
} | ||
|
||
public function testFailsSayWithNoValueParameter1() | ||
{ | ||
try{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,25 @@ class OnTest extends TestCase{ | |
|
||
public function testCreateOnObject() { | ||
|
||
$strSession = '{"session":{"id":"35b00c154f2fecacba37fad74e64a7e2","accountId":"1","applicationId":"1","timestamp":"2017-06-08T03:40:19.283Z","userType":"HUMAN","initialText":null,"callId":"c5b298fc0785fda9029f7f3b5aeef7ab","to":{"id":"9992801029","e164Id":"9992801029","name":"9992801029","channel":"VOICE","network":"SIP"},"from":{"id":"pengxli","e164Id":"pengxli","name":"pengxli","channel":"VOICE","network":"SIP"},"headers":{"Call-ID":"83369NTAxNDI2NDA4MWMzYTBiNzBiNmM0ZTVlMTQ4NjRlNmY","CSeq":"1 INVITE","Max-Forwards":"69","Request URI":"sip:[email protected];x-rt=0","Record-Route":"<sip:192.168.26.111:5060;transport=udp;lr>","x-sid":"6f1e3b7b2ace2a7785780b6337641388","User-Agent":"X-Lite release 4.9.7.1 stamp 83369","From":"<sip:[email protected]>;tag=1bb1ef33","Supported":"replaces","Allow":"SUBSCRIBE\\r\\nNOTIFY\\r\\nINVITE\\r\\nACK\\r\\nCANCEL\\r\\nBYE\\r\\nREFER\\r\\nINFO\\r\\nOPTIONS\\r\\nMESSAGE","Via":"SIP/2.0/UDP 192.168.26.111:5060;branch=z9hG4bK1vxcouwp4r78j;rport=5060\\r\\nSIP/2.0/UDP 192.168.26.1:5678;branch=z9hG4bK-524287-1---b1f649005b368755;rport=5678","Contact":"<sip:[email protected]:5678>","To":"<sip:[email protected]>","Content-Length":"335","Content-Type":"application/sdp"}}}'; | ||
$strSession = '{"session":{"id":"35b00c154f2fecacba37fad74e64a7e2","accountId":"1","applicationId":"1","timestamp":"2017-06-08T03:40:19.283Z","userType":"HUMAN","initialText":null,"subject": "Inbound MMS subject","initialMedia":[{"status":"success","media": "http://filehosting.tropo.com/account/1.jpg"},{"status":"success","text": "this is text"},{"status":"failure","disposition": "Failed to upload: 500 Internal Error","media": "2.jpg"}],"callId":"c5b298fc0785fda9029f7f3b5aeef7ab","to":{"id":"9992801029","e164Id":"9992801029","name":"9992801029","channel":"VOICE","network":"SIP"},"from":{"id":"pengxli","e164Id":"pengxli","name":"pengxli","channel":"VOICE","network":"SIP"},"headers":{"Call-ID":"83369NTAxNDI2NDA4MWMzYTBiNzBiNmM0ZTVlMTQ4NjRlNmY","CSeq":"1 INVITE","Max-Forwards":"69","Request URI":"sip:[email protected];x-rt=0","Record-Route":"<sip:192.168.26.111:5060;transport=udp;lr>","x-sid":"6f1e3b7b2ace2a7785780b6337641388","User-Agent":"X-Lite release 4.9.7.1 stamp 83369","From":"<sip:[email protected]>;tag=1bb1ef33","Supported":"replaces","Allow":"SUBSCRIBE\\r\\nNOTIFY\\r\\nINVITE\\r\\nACK\\r\\nCANCEL\\r\\nBYE\\r\\nREFER\\r\\nINFO\\r\\nOPTIONS\\r\\nMESSAGE","Via":"SIP/2.0/UDP 192.168.26.111:5060;branch=z9hG4bK1vxcouwp4r78j;rport=5060\\r\\nSIP/2.0/UDP 192.168.26.1:5678;branch=z9hG4bK-524287-1---b1f649005b368755;rport=5678","Contact":"<sip:[email protected]:5678>","To":"<sip:[email protected]>","Content-Length":"335","Content-Type":"application/sdp"}}}'; | ||
$session = new Session($strSession); | ||
$this->assertEquals($session->getId(), '35b00c154f2fecacba37fad74e64a7e2'); | ||
$this->assertEquals($session->getAccountId(), '1'); | ||
$this->assertEquals($session->getTimestamp(), '2017-06-08T03:40:19.283Z'); | ||
$this->assertEquals($session->getUserType(), 'HUMAN'); | ||
$this->assertEquals($session->getInitialText(), null); | ||
$initialMedia = $session->getInitialMedia(); | ||
$this->assertEquals($session->getStatusFromMedia($initialMedia[0]), "success"); | ||
$this->assertEquals($session->getMediaFromMedia($initialMedia[0]), "http://filehosting.tropo.com/account/1.jpg"); | ||
|
||
$this->assertEquals($session->getStatusFromMedia($initialMedia[1]), "success"); | ||
$this->assertEquals($session->getTextFromMedia($initialMedia[1]), "this is text"); | ||
|
||
$this->assertEquals($session->getStatusFromMedia($initialMedia[2]), "failure"); | ||
$this->assertEquals($session->getDispositionFromMedia($initialMedia[2]), "Failed to upload: 500 Internal Error"); | ||
$this->assertEquals($session->getMediaFromMedia($initialMedia[2]), "2.jpg"); | ||
|
||
$this->assertEquals($session->getSubject(), "Inbound MMS subject"); | ||
$this->assertEquals($session->getCallId(), 'c5b298fc0785fda9029f7f3b5aeef7ab'); | ||
$to = $session->getTo(); | ||
$this->assertEquals($to["id"], '9992801029'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters