';
$this->assertXmlStringEqualsXmlString($expected, $r,
"Should be an empty response");
}
public function testSayBasic() {
$r = new Services_Twilio_Twiml();
$r->say("Hello Monkey");
$expected = 'Hello Monkey';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testSayLoopThree() {
$r = new Services_Twilio_Twiml();
$r->say("Hello Monkey", array("loop" => 3));
$expected = 'Hello Monkey';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testSayLoopThreeWoman() {
$r = new Services_Twilio_Twiml();
$r->say("Hello Monkey", array("loop" => 3, "voice"=>"woman"));
$expected = ''
. 'Hello Monkey';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testSayConvienceMethod() {
$r = new Services_Twilio_Twiml();
$r->say("Hello Monkey", array("language" => "fr"));
$expected = ''
. 'Hello Monkey';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testSayUTF8() {
$r = new Services_Twilio_Twiml();
$r->say("é tü & må");
$expected = ''
. 'é tü & må';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testSayNamedEntities() {
$r = new Services_Twilio_Twiml();
$r->say("é tü & må");
$expected = ''
. 'é tü & må';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testSayNumericEntities() {
$r = new Services_Twilio_Twiml();
$r->say("é tü & må");
$expected = ''
. 'é tü & må';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testPlayBasic() {
$r = new Services_Twilio_Twiml();
$r->play("hello-monkey.mp3");
$expected = 'hello-monkey.mp3';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testPlayLoopThree() {
$r = new Services_Twilio_Twiml();
$r->play("hello-monkey.mp3", array("loop" => 3));
$expected = ''
. 'hello-monkey.mp3';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testPlayConvienceMethod() {
$r = new Services_Twilio_Twiml();
$r->play("hello-monkey.mp3", array("loop" => 3));
$expected = ''
. 'hello-monkey.mp3';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
//Test Record Verb
public function testRecord() {
$r = new Services_Twilio_Twiml();
$r->record();
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testRecordActionMethod() {
$r = new Services_Twilio_Twiml();
$r->record(array("action" => "example.com", "method" => "GET"));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testBooleanBecomesString() {
$r = new Services_Twilio_Twiml();
$r->record(array("transcribe" => true));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testRecordMaxLengthKeyTimeout(){
$r = new Services_Twilio_Twiml();
$r->record(array("timeout" => 4, "finishOnKey" => "#",
"maxLength" => 30));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testRecordConvienceMethod(){
$r = new Services_Twilio_Twiml();
$r->record(array("transcribeCallback" => "example.com"));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testRecordAddAttribute(){
$r = new Services_Twilio_Twiml();
$r->record(array("foo" => "bar"));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
//Test Redirect Verb
public function testRedirect() {
$r = new Services_Twilio_Twiml();
$r->redirect();
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testAmpersandEscaping() {
$r = new Services_Twilio_Twiml();
$test_amp = "test&two&three";
$r->redirect($test_amp);
$expected = '' .
'test&two&three';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testRedirectConvience() {
$r = new Services_Twilio_Twiml();
$r->redirect();
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testRedirectAddAttribute(){
$r = new Services_Twilio_Twiml();
$r->redirect(array("foo" => "bar"));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
//Test Hangup Verb
public function testHangup() {
$r = new Services_Twilio_Twiml();
$r->hangup();
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testHangupConvience() {
$r = new Services_Twilio_Twiml();
$r->hangup();
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testHangupAddAttribute(){
$r = new Services_Twilio_Twiml();
$r->hangup(array("foo" => "bar"));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
//Test Pause Verb
public function testPause() {
$r = new Services_Twilio_Twiml();
$r->pause();
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testPauseConvience() {
$r = new Services_Twilio_Twiml();
$r->pause();
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testPauseAddAttribute(){
$r = new Services_Twilio_Twiml();
$r->pause(array("foo" => "bar"));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
//Test Dial Verb
public function testDial() {
$r = new Services_Twilio_Twiml();
$r->dial("1231231234");
$expected = '1231231234';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testDialConvience() {
$r = new Services_Twilio_Twiml();
$r->dial();
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testDialAddNumber() {
$r = new Services_Twilio_Twiml();
$d = $r->dial();
$d->number("1231231234");
$expected = ''
. '1231231234';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testDialAddConference() {
$r = new Services_Twilio_Twiml();
$d = $r->dial();
$d->conference("MyRoom");
$expected = ''
. 'MyRoom';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testDialAddConferenceConvience() {
$r = new Services_Twilio_Twiml();
$d = $r->dial();
$d->conference("MyRoom", array("startConferenceOnEnter" => "false"));
$expected = 'MyRoom';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testDialAddAttribute() {
$r = new Services_Twilio_Twiml();
$r->dial(array("foo" => "bar"));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
//Test Gather Verb
public function testGather() {
$r = new Services_Twilio_Twiml();
$r->gather();
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testGatherMethodAction(){
$r = new Services_Twilio_Twiml();
$r->gather(array("action"=>"example.com", "method"=>"GET"));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testGatherActionWithParams(){
$r = new Services_Twilio_Twiml();
$r->gather(array("action" => "record.php?action=recordPageNow"
. "&id=4&page=3"));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testGatherNestedVerbs(){
$r = new Services_Twilio_Twiml();
$g = $r->gather(array("action"=>"example.com", "method"=>"GET"));
$g->say("Hello World");
$g->play("helloworld.mp3");
$g->pause();
$expected = '
Hello World
helloworld.mp3
';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testGatherNestedVerbsConvienceMethods(){
$r = new Services_Twilio_Twiml();
$g = $r->gather(array("action"=>"example.com", "method"=>"GET"));
$g->say("Hello World");
$g->play("helloworld.mp3");
$g->pause();
$expected = '
Hello World
helloworld.mp3
';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testGatherAddAttribute(){
$r = new Services_Twilio_Twiml();
$r->gather(array("foo" => "bar"));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testSms() {
$r = new Services_Twilio_Twiml();
$r->sms("Hello World");
$expected = 'Hello World';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testSmsConvience() {
$r = new Services_Twilio_Twiml();
$r->sms("Hello World");
$expected = 'Hello World';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testSmsAddAttribute() {
$r = new Services_Twilio_Twiml();
$r->sms(array("foo" => "bar"));
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
public function testReject() {
$r = new Services_Twilio_Twiml();
$r->reject();
$expected = '';
$this->assertXmlStringEqualsXmlString($expected, $r);
}
function testGeneration() {
$r = new Services_Twilio_Twiml();
$r->say('hello');
$r->dial()->number('123', array('sendDigits' => '456'));
$r->gather(array('timeout' => 15));
$doc = simplexml_load_string($r);
$this->assertEquals('Response', $doc->getName());
$this->assertEquals('hello', (string) $doc->Say);
$this->assertEquals('456', (string) $doc->Dial->Number['sendDigits']);
$this->assertEquals('123', (string) $doc->Dial->Number);
$this->assertEquals('15', (string) $doc->Gather['timeout']);
}
}