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.
Add answer to TROPO JSON helper library with support for RPID paramet…
…ers - WebAPI PHP
- Loading branch information
Showing
2 changed files
with
108 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
use PHPUnit\Framework\TestCase; | ||
require_once 'tropo.class.php'; | ||
|
||
class AnswerTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testCallWithMinOptions() { | ||
$tropo = new Tropo(); | ||
$tropo->answer(); | ||
$params = array("name"=>"say"); | ||
$tropo->say("Hello, you were the first to answer.",$params); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"answer":{}},{"say":[{"value":"Hello, you were the first to answer.","name":"say"}]}]}'); | ||
} | ||
|
||
public function testCallWithMinOptions1() { | ||
$tropo = new Tropo(); | ||
$tropo->answer(null); | ||
$params = array("name"=>"say"); | ||
$tropo->say("Hello, you were the first to answer.",$params); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"answer":{}},{"say":[{"value":"Hello, you were the first to answer.","name":"say"}]}]}'); | ||
} | ||
|
||
public function testCallWithExtraToOptiions() { | ||
$tropo = new Tropo(); | ||
$params = array( | ||
'headers' => array( | ||
'P-Header' => 'value goes here', | ||
'Remote-Party-ID' => '"John Doe"<sip:[email protected]>;party=calling;id-type=subscriber;privacy=full;screen=yes' | ||
)); | ||
$tropo->answer($params); | ||
$params = array("name"=>"say"); | ||
$tropo->say("Hello, you were the first to answer.",$params); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"answer":{"headers":{"P-Header":"value goes here","Remote-Party-ID":"\"John Doe\"<sip:[email protected]>;party=calling;id-type=subscriber;privacy=full;screen=yes"}}},{"say":[{"value":"Hello, you were the first to answer.","name":"say"}]}]}'); | ||
} | ||
|
||
public function testCreateMinObject() { | ||
$tropo = new Tropo(); | ||
$answer = new Answer(); | ||
$tropo->answer($answer); | ||
$params = array("name"=>"say"); | ||
$tropo->say("Hello, you were the first to answer.",$params); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"answer":{}},{"say":[{"value":"Hello, you were the first to answer.","name":"say"}]}]}'); | ||
} | ||
|
||
public function testCreateMinObject1() { | ||
$tropo = new Tropo(); | ||
$headers = array( | ||
'P-Header' => 'value goes here', | ||
'Remote-Party-ID' => '"John Doe"<sip:[email protected]>;party=calling;id-type=subscriber;privacy=full;screen=yes' | ||
); | ||
$answer = new Answer($headers); | ||
$tropo->answer($answer); | ||
$params = array("name"=>"say"); | ||
$tropo->say("Hello, you were the first to answer.",$params); | ||
$this->assertEquals(sprintf($tropo), '{"tropo":[{"answer":{"headers":{"P-Header":"value goes here","Remote-Party-ID":"\"John Doe\"<sip:[email protected]>;party=calling;id-type=subscriber;privacy=full;screen=yes"}}},{"say":[{"value":"Hello, you were the first to answer.","name":"say"}]}]}'); | ||
} | ||
|
||
} | ||
?> |
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