Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Voice/Bxml/Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ public function fallbackPassword($fallbackPassword) {
}

public function toBxml($doc) {
$element = $doc->createElement("Bridge", $this->targetCall);
$element = $doc->createElement("Bridge");

$element->appendChild($doc->createTextNode($this->targetCall));

if(isset($this->bridgeCompleteUrl)) {
$element->setAttribute("bridgeCompleteUrl", $this->bridgeCompleteUrl);
Expand Down
4 changes: 3 additions & 1 deletion src/Voice/Bxml/Conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ public function fallbackPassword($fallbackPassword) {
}

public function toBxml($doc) {
$element = $doc->createElement("Conference", $this->conferenceName);
$element = $doc->createElement("Conference");

$element->appendChild($doc->createTextNode($this->conferenceName));

if(isset($this->username)) {
$element->setattribute("username", $this->username);
Expand Down
4 changes: 3 additions & 1 deletion src/Voice/Bxml/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ public function fallbackPassword($fallbackPassword) {
}

public function toBxml($doc) {
$element = $doc->createElement("PhoneNumber", $this->phoneNumber);
$element = $doc->createElement("PhoneNumber");

$element->appendChild($doc->createTextNode($this->phoneNumber));

if(isset($this->username)) {
$element->setAttribute("username", $this->username);
Expand Down
4 changes: 3 additions & 1 deletion src/Voice/Bxml/PlayAudio.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function password($password) {
}

public function toBxml($doc) {
$element = $doc->createElement("PlayAudio", $this->url);
$element = $doc->createElement("PlayAudio");

$element->appendChild($doc->createTextNode($this->url));

if(isset($this->username)) {
$element->setAttribute("username", $this->username);
Expand Down
5 changes: 0 additions & 5 deletions src/Voice/Bxml/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public function __construct() {
* @param Verb $verb The verb to add to the list
*/
public function addVerb($verb) {
foreach($verb as $key => $value) { // encodes any verb attributes of type string to avoid php character encoding bug
if(gettype($value) == "string") {
$verb->$key = htmlspecialchars($value, ENT_XML1, 'UTF-8');
}
}
array_push($this->verbs, $verb);
}

Expand Down
4 changes: 3 additions & 1 deletion src/Voice/Bxml/SendDtmf.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function toneInterval($toneInterval) {
}

public function toBxml($doc) {
$element = $doc->createElement("SendDtmf", $this->digits);
$element = $doc->createElement("SendDtmf");

$element->appendChild($doc->createTextNode($this->digits));

if(isset($this->toneDuration)) {
$element->setattribute("toneDuration", $this->toneDuration);
Expand Down
4 changes: 3 additions & 1 deletion src/Voice/Bxml/SipUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ public function fallbackPassword($fallbackPassword) {
}

public function toBxml($doc) {
$element = $doc->createElement("SipUri", $this->sip);
$element = $doc->createElement("SipUri");

$element->appendChild($doc->createTextNode($this->sip));

if(isset($this->username)) {
$element->setAttribute("username", $this->username);
Expand Down
4 changes: 3 additions & 1 deletion src/Voice/Bxml/SpeakSentence.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public function gender($gender) {
}

public function toBxml($doc) {
$element = $doc->createElement("SpeakSentence", $this->sentence);
$element = $doc->createElement("SpeakSentence");

$element->appendChild($doc->createTextNode($this->sentence));

if(isset($this->locale)) {
$element->setAttribute("locale", $this->locale);
Expand Down
4 changes: 3 additions & 1 deletion src/Voice/Bxml/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public function __construct($tag) {
}

public function toBxml($doc) {
$element = $doc->createElement("Tag", $this->tag);
$element = $doc->createElement("Tag");

$element->appendChild($doc->createTextNode($this->tag));

return $element;
}
Expand Down
34 changes: 34 additions & 0 deletions tests/BxmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,29 @@ public function testGatherNoNestedTag() {
$this->assertEquals($expectedXml, $responseXml);
}

public function testGatherEncodedURL() {
$gather = new BandwidthLib\Voice\Bxml\Gather();
$gather->gatherUrl("https://test.com?param1=test1&param2=test2");
$gather->gatherMethod("GET");
$gather->username("user");
$gather->password("pass");
$gather->tag("tag");
$gather->terminatingDigits("123");
$gather->maxDigits(3);
$gather->interDigitTimeout(4);
$gather->firstDigitTimeout(5);
$gather->repeatCount(3);
$gather->gatherFallbackUrl("https://test.com");
$gather->gatherFallbackMethod("GET");
$gather->fallbackUsername("fuser");
$gather->fallbackPassword("fpass");
$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($gather);
$expectedXml = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather username="user" password="pass" tag="tag" gatherUrl="https://test.com?param1=test1&amp;param2=test2" gatherMethod="GET" terminatingDigits="123" maxDigits="3" interDigitTimeout="4" firstDigitTimeout="5" repeatCount="3" gatherFallbackUrl="https://test.com" gatherFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"/></Response>';
$responseXml = $response->toBxml();
$this->assertEquals($expectedXml, $responseXml);
}

public function testGatherNestedSpeakSentence() {
$gather = new BandwidthLib\Voice\Bxml\Gather();
$speakSentence = new BandwidthLib\Voice\Bxml\SpeakSentence("Test");
Expand Down Expand Up @@ -210,6 +233,17 @@ public function testPlayAudio() {
$this->assertEquals($expectedXml, $responseXml);
}

public function testPlayAudioEncodedURL() {
$playAudio = new BandwidthLib\Voice\Bxml\PlayAudio("https://test.com?param1=test1&param2=test2");
$playAudio->username("user");
$playAudio->password("pass");
$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($playAudio);
$expectedXml = '<?xml version="1.0" encoding="UTF-8"?><Response><PlayAudio username="user" password="pass">https://test.com?param1=test1&amp;param2=test2</PlayAudio></Response>';
$responseXml = $response->toBxml();
$this->assertEquals($expectedXml, $responseXml);
}

public function testTransfer() {
$number1 = new BandwidthLib\Voice\Bxml\PhoneNumber("+17777777777");
$number1->transferAnswerUrl("https://test.com");
Expand Down