| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,153 +0,0 @@ |
| 1 |
-<?php |
|
| 2 |
- |
|
| 3 |
-use Plivo\Tests\BaseTestCase; |
|
| 4 |
-use Plivo\XML\Response; |
|
| 5 |
- |
|
| 6 |
- |
|
| 7 |
-/** |
|
| 8 |
- * Class AccountTest |
|
| 9 |
- * @package Plivo\Tests\Resources |
|
| 10 |
- */ |
|
| 11 |
-class XmlTest extends BaseTestCase |
|
| 12 |
-{
|
|
| 13 |
- /** |
|
| 14 |
- * |
|
| 15 |
- */ |
|
| 16 |
- function testXml() |
|
| 17 |
- {
|
|
| 18 |
- $resp = new Response(); |
|
| 19 |
- $resp->addConference("My room",
|
|
| 20 |
- ['callbackUrl' => "http://foo.com/confevents/", |
|
| 21 |
- 'callbackMethod' => "POST", |
|
| 22 |
- 'digitsMatch' => "#0,99,000"]); |
|
| 23 |
- |
|
| 24 |
- $dial = $resp->addDial( |
|
| 25 |
- [ |
|
| 26 |
- 'confirmSound' => "http://foo.com/sound/", |
|
| 27 |
- 'confirmKey' => "3" |
|
| 28 |
- ]); |
|
| 29 |
- $dial->addNumber("18217654321",
|
|
| 30 |
- [ |
|
| 31 |
- 'sendDigits' => "wwww2410" |
|
| 32 |
- ]); |
|
| 33 |
- $dial->addUser("sip:john1234@phone.plivo.com",
|
|
| 34 |
- [ |
|
| 35 |
- 'sendDigits' => "wwww2410" |
|
| 36 |
- ]); |
|
| 37 |
- |
|
| 38 |
- $dial1 = $resp->addDial( |
|
| 39 |
- [ |
|
| 40 |
- 'timeout' => "20", |
|
| 41 |
- 'action' => "http://oo.com/dial_action/" |
|
| 42 |
- ]); |
|
| 43 |
- |
|
| 44 |
- $dial1->addNumber("18217654321", []);
|
|
| 45 |
- |
|
| 46 |
- $dial2 = $resp->addDial([]); |
|
| 47 |
- $dial2->addNumber("15671234567", []);
|
|
| 48 |
- |
|
| 49 |
- $resp->addDTMF("12345", []);
|
|
| 50 |
- |
|
| 51 |
- $get_digits = $resp->addGetDigits( |
|
| 52 |
- [ |
|
| 53 |
- 'action' => "http://www.foo.com/gather_pin/", |
|
| 54 |
- "method" => "POST" |
|
| 55 |
- ]); |
|
| 56 |
- |
|
| 57 |
- $get_digits->addSpeak("Enter PIN number.", []);
|
|
| 58 |
- |
|
| 59 |
- $get_input = $resp->addGetInput( |
|
| 60 |
- [ |
|
| 61 |
- 'action' => "http://www.foo.com/gather_feedback", |
|
| 62 |
- "method" => "GET" |
|
| 63 |
- ]); |
|
| 64 |
- $get_input->addSpeak("Tell us more about your experience.", []);
|
|
| 65 |
- |
|
| 66 |
- $resp->addSpeak("Input not recieved.", []);
|
|
| 67 |
- |
|
| 68 |
- $resp->addHangup( |
|
| 69 |
- [ |
|
| 70 |
- 'schedule' => "60", |
|
| 71 |
- 'reason' => "rejected" |
|
| 72 |
- ]); |
|
| 73 |
- $resp->addSpeak("Call will hangup after a min.",
|
|
| 74 |
- [ |
|
| 75 |
- 'loop' => "0" |
|
| 76 |
- ]); |
|
| 77 |
- |
|
| 78 |
- $resp->addMessage("Hi, message from Plivo.",
|
|
| 79 |
- [ |
|
| 80 |
- 'src' => "12023222222", |
|
| 81 |
- 'dst' => "15671234567" , |
|
| 82 |
- 'type' => "sms", |
|
| 83 |
- 'callbackUrl' => "http://foo.com/sms_status/", |
|
| 84 |
- 'callbackMethod' => "POST" |
|
| 85 |
- ]); |
|
| 86 |
- |
|
| 87 |
- $resp->addPlay("https://amazonaws.com/Trumpet.mp3", []);
|
|
| 88 |
- |
|
| 89 |
- $answer = $resp->addPreAnswer(); |
|
| 90 |
- $answer->addSpeak("This call will cost $2 a min.", []);
|
|
| 91 |
- $resp->addSpeak("Thanks for dropping by.", []);
|
|
| 92 |
- |
|
| 93 |
- $resp->addRecord( |
|
| 94 |
- [ |
|
| 95 |
- 'action' => "http://foo.com/get_recording/", |
|
| 96 |
- 'startOnDialAnswer' => "true", |
|
| 97 |
- 'redirect' => "false" |
|
| 98 |
- ]); |
|
| 99 |
- |
|
| 100 |
- $dial3 = $resp->addDial([]); |
|
| 101 |
- |
|
| 102 |
- $dial3->addNumber("15551234567", []);
|
|
| 103 |
- |
|
| 104 |
- $resp->addSpeak("Leave message after the beep.", []);
|
|
| 105 |
- $resp->addRecord( |
|
| 106 |
- [ |
|
| 107 |
- 'action' => "http://foo.com/get_recording/", |
|
| 108 |
- 'maxLength' => "30", |
|
| 109 |
- 'finishOnKey' => "*" |
|
| 110 |
- ]); |
|
| 111 |
- $resp->addSpeak("Recording not received.", []);
|
|
| 112 |
- |
|
| 113 |
- $resp->addSpeak("Your call is being transferred.", []);
|
|
| 114 |
- $resp->addRedirect("http://foo.com/redirect/", []);
|
|
| 115 |
- |
|
| 116 |
- $resp->addSpeak("Go green, go plivo.",
|
|
| 117 |
- [ |
|
| 118 |
- 'loop' => "3" |
|
| 119 |
- ]); |
|
| 120 |
- |
|
| 121 |
- $resp->addSpeak("I will wait 7 seconds starting now!", []);
|
|
| 122 |
- $resp->addWait( |
|
| 123 |
- [ |
|
| 124 |
- 'length' => "7" |
|
| 125 |
- ]); |
|
| 126 |
- $resp->addSpeak("I just waited 7 seconds.", []);
|
|
| 127 |
- |
|
| 128 |
- $resp->addWait( |
|
| 129 |
- [ |
|
| 130 |
- 'length' => "120", 'beep' => "true" |
|
| 131 |
- ]); |
|
| 132 |
- $resp->addPlay("https://s3.amazonaws.com/abc.mp3", []);
|
|
| 133 |
- |
|
| 134 |
- $resp->addWait( |
|
| 135 |
- [ |
|
| 136 |
- 'length' => "10" |
|
| 137 |
- ]); |
|
| 138 |
- $resp->addSpeak("Hello", []);
|
|
| 139 |
- |
|
| 140 |
- $resp->addWait( |
|
| 141 |
- [ |
|
| 142 |
- 'length' => "10", |
|
| 143 |
- 'silence' => "true", |
|
| 144 |
- 'minSilence' => "3000" |
|
| 145 |
- ]); |
|
| 146 |
- $resp->addSpeak("Hello, welcome to the Jungle.", []);
|
|
| 147 |
- |
|
| 148 |
- $output = $resp->toXML(true); |
|
| 149 |
- self::assertEquals( |
|
| 150 |
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Response><Conference callbackUrl=\"http://foo.com/confevents/\" callbackMethod=\"POST\" digitsMatch=\"#0,99,000\">My room</Conference><Dial confirmSound=\"http://foo.com/sound/\" confirmKey=\"3\"><Number sendDigits=\"wwww2410\">18217654321</Number><User sendDigits=\"wwww2410\">sip:john1234@phone.plivo.com</User></Dial><Dial timeout=\"20\" action=\"http://oo.com/dial_action/\"><Number>18217654321</Number></Dial><Dial><Number>15671234567</Number></Dial><DTMF>12345</DTMF><GetDigits action=\"http://www.foo.com/gather_pin/\" method=\"POST\"><Speak voice=\"WOMAN\">Enter PIN number.</Speak></GetDigits><GetInput action=\"http://www.foo.com/gather_feedback\" method=\"GET\"><Speak voice=\"WOMAN\">Tell us more about your experience.</Speak></GetInput><Speak voice=\"WOMAN\">Input not recieved.</Speak><Hangup schedule=\"60\" reason=\"rejected\"/><Speak loop=\"0\" voice=\"WOMAN\">Call will hangup after a min.</Speak><Message src=\"12023222222\" dst=\"15671234567\" type=\"sms\" callbackUrl=\"http://foo.com/sms_status/\" callbackMethod=\"POST\">Hi, message from Plivo.</Message><Play>https://amazonaws.com/Trumpet.mp3</Play><PreAnswer><Speak voice=\"WOMAN\">This call will cost $2 a min.</Speak></PreAnswer><Speak voice=\"WOMAN\">Thanks for dropping by.</Speak><Record action=\"http://foo.com/get_recording/\" startOnDialAnswer=\"true\" redirect=\"false\"/><Dial><Number>15551234567</Number></Dial><Speak voice=\"WOMAN\">Leave message after the beep.</Speak><Record action=\"http://foo.com/get_recording/\" maxLength=\"30\" finishOnKey=\"*\"/><Speak voice=\"WOMAN\">Recording not received.</Speak><Speak voice=\"WOMAN\">Your call is being transferred.</Speak><Redirect>http://foo.com/redirect/</Redirect><Speak loop=\"3\" voice=\"WOMAN\">Go green, go plivo.</Speak><Speak voice=\"WOMAN\">I will wait 7 seconds starting now!</Speak><Wait length=\"7\"/><Speak voice=\"WOMAN\">I just waited 7 seconds.</Speak><Wait length=\"120\" beep=\"true\"/><Play>https://s3.amazonaws.com/abc.mp3</Play><Wait length=\"10\"/><Speak voice=\"WOMAN\">Hello</Speak><Wait length=\"10\" silence=\"true\" minSilence=\"3000\"/><Speak voice=\"WOMAN\">Hello, welcome to the Jungle.</Speak></Response>\n", |
|
| 151 |
- $output); |
|
| 152 |
- } |
|
| 153 |
-} |
|
| 154 | 0 |
\ No newline at end of file |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,153 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+use Plivo\Tests\BaseTestCase; |
|
| 4 |
+use Plivo\XML\Response; |
|
| 5 |
+ |
|
| 6 |
+ |
|
| 7 |
+/** |
|
| 8 |
+ * Class AccountTest |
|
| 9 |
+ * @package Plivo\Tests\Resources |
|
| 10 |
+ */ |
|
| 11 |
+class XmlTest extends BaseTestCase |
|
| 12 |
+{
|
|
| 13 |
+ /** |
|
| 14 |
+ * |
|
| 15 |
+ */ |
|
| 16 |
+ function testXml() |
|
| 17 |
+ {
|
|
| 18 |
+ $resp = new Response(); |
|
| 19 |
+ $resp->addConference("My room",
|
|
| 20 |
+ ['callbackUrl' => "http://foo.com/confevents/", |
|
| 21 |
+ 'callbackMethod' => "POST", |
|
| 22 |
+ 'digitsMatch' => "#0,99,000"]); |
|
| 23 |
+ |
|
| 24 |
+ $dial = $resp->addDial( |
|
| 25 |
+ [ |
|
| 26 |
+ 'confirmSound' => "http://foo.com/sound/", |
|
| 27 |
+ 'confirmKey' => "3" |
|
| 28 |
+ ]); |
|
| 29 |
+ $dial->addNumber("18217654321",
|
|
| 30 |
+ [ |
|
| 31 |
+ 'sendDigits' => "wwww2410" |
|
| 32 |
+ ]); |
|
| 33 |
+ $dial->addUser("sip:john1234@phone.plivo.com",
|
|
| 34 |
+ [ |
|
| 35 |
+ 'sendDigits' => "wwww2410" |
|
| 36 |
+ ]); |
|
| 37 |
+ |
|
| 38 |
+ $dial1 = $resp->addDial( |
|
| 39 |
+ [ |
|
| 40 |
+ 'timeout' => "20", |
|
| 41 |
+ 'action' => "http://oo.com/dial_action/" |
|
| 42 |
+ ]); |
|
| 43 |
+ |
|
| 44 |
+ $dial1->addNumber("18217654321", []);
|
|
| 45 |
+ |
|
| 46 |
+ $dial2 = $resp->addDial([]); |
|
| 47 |
+ $dial2->addNumber("15671234567", []);
|
|
| 48 |
+ |
|
| 49 |
+ $resp->addDTMF("12345", []);
|
|
| 50 |
+ |
|
| 51 |
+ $get_digits = $resp->addGetDigits( |
|
| 52 |
+ [ |
|
| 53 |
+ 'action' => "http://www.foo.com/gather_pin/", |
|
| 54 |
+ "method" => "POST" |
|
| 55 |
+ ]); |
|
| 56 |
+ |
|
| 57 |
+ $get_digits->addSpeak("Enter PIN number.", []);
|
|
| 58 |
+ |
|
| 59 |
+ $get_input = $resp->addGetInput( |
|
| 60 |
+ [ |
|
| 61 |
+ 'action' => "http://www.foo.com/gather_feedback", |
|
| 62 |
+ "method" => "GET" |
|
| 63 |
+ ]); |
|
| 64 |
+ $get_input->addSpeak("Tell us more about your experience.", []);
|
|
| 65 |
+ |
|
| 66 |
+ $resp->addSpeak("Input not recieved.", []);
|
|
| 67 |
+ |
|
| 68 |
+ $resp->addHangup( |
|
| 69 |
+ [ |
|
| 70 |
+ 'schedule' => "60", |
|
| 71 |
+ 'reason' => "rejected" |
|
| 72 |
+ ]); |
|
| 73 |
+ $resp->addSpeak("Call will hangup after a min.",
|
|
| 74 |
+ [ |
|
| 75 |
+ 'loop' => "0" |
|
| 76 |
+ ]); |
|
| 77 |
+ |
|
| 78 |
+ $resp->addMessage("Hi, message from Plivo.",
|
|
| 79 |
+ [ |
|
| 80 |
+ 'src' => "12023222222", |
|
| 81 |
+ 'dst' => "15671234567" , |
|
| 82 |
+ 'type' => "sms", |
|
| 83 |
+ 'callbackUrl' => "http://foo.com/sms_status/", |
|
| 84 |
+ 'callbackMethod' => "POST" |
|
| 85 |
+ ]); |
|
| 86 |
+ |
|
| 87 |
+ $resp->addPlay("https://amazonaws.com/Trumpet.mp3", []);
|
|
| 88 |
+ |
|
| 89 |
+ $answer = $resp->addPreAnswer(); |
|
| 90 |
+ $answer->addSpeak("This call will cost $2 a min.", []);
|
|
| 91 |
+ $resp->addSpeak("Thanks for dropping by.", []);
|
|
| 92 |
+ |
|
| 93 |
+ $resp->addRecord( |
|
| 94 |
+ [ |
|
| 95 |
+ 'action' => "http://foo.com/get_recording/", |
|
| 96 |
+ 'startOnDialAnswer' => "true", |
|
| 97 |
+ 'redirect' => "false" |
|
| 98 |
+ ]); |
|
| 99 |
+ |
|
| 100 |
+ $dial3 = $resp->addDial([]); |
|
| 101 |
+ |
|
| 102 |
+ $dial3->addNumber("15551234567", []);
|
|
| 103 |
+ |
|
| 104 |
+ $resp->addSpeak("Leave message after the beep.", []);
|
|
| 105 |
+ $resp->addRecord( |
|
| 106 |
+ [ |
|
| 107 |
+ 'action' => "http://foo.com/get_recording/", |
|
| 108 |
+ 'maxLength' => "30", |
|
| 109 |
+ 'finishOnKey' => "*" |
|
| 110 |
+ ]); |
|
| 111 |
+ $resp->addSpeak("Recording not received.", []);
|
|
| 112 |
+ |
|
| 113 |
+ $resp->addSpeak("Your call is being transferred.", []);
|
|
| 114 |
+ $resp->addRedirect("http://foo.com/redirect/", []);
|
|
| 115 |
+ |
|
| 116 |
+ $resp->addSpeak("Go green, go plivo.",
|
|
| 117 |
+ [ |
|
| 118 |
+ 'loop' => "3" |
|
| 119 |
+ ]); |
|
| 120 |
+ |
|
| 121 |
+ $resp->addSpeak("I will wait 7 seconds starting now!", []);
|
|
| 122 |
+ $resp->addWait( |
|
| 123 |
+ [ |
|
| 124 |
+ 'length' => "7" |
|
| 125 |
+ ]); |
|
| 126 |
+ $resp->addSpeak("I just waited 7 seconds.", []);
|
|
| 127 |
+ |
|
| 128 |
+ $resp->addWait( |
|
| 129 |
+ [ |
|
| 130 |
+ 'length' => "120", 'beep' => "true" |
|
| 131 |
+ ]); |
|
| 132 |
+ $resp->addPlay("https://s3.amazonaws.com/abc.mp3", []);
|
|
| 133 |
+ |
|
| 134 |
+ $resp->addWait( |
|
| 135 |
+ [ |
|
| 136 |
+ 'length' => "10" |
|
| 137 |
+ ]); |
|
| 138 |
+ $resp->addSpeak("Hello", []);
|
|
| 139 |
+ |
|
| 140 |
+ $resp->addWait( |
|
| 141 |
+ [ |
|
| 142 |
+ 'length' => "10", |
|
| 143 |
+ 'silence' => "true", |
|
| 144 |
+ 'minSilence' => "3000" |
|
| 145 |
+ ]); |
|
| 146 |
+ $resp->addSpeak("Hello, welcome to the Jungle.", []);
|
|
| 147 |
+ |
|
| 148 |
+ $output = $resp->toXML(true); |
|
| 149 |
+ self::assertEquals( |
|
| 150 |
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Response><Conference callbackUrl=\"http://foo.com/confevents/\" callbackMethod=\"POST\" digitsMatch=\"#0,99,000\">My room</Conference><Dial confirmSound=\"http://foo.com/sound/\" confirmKey=\"3\"><Number sendDigits=\"wwww2410\">18217654321</Number><User sendDigits=\"wwww2410\">sip:john1234@phone.plivo.com</User></Dial><Dial timeout=\"20\" action=\"http://oo.com/dial_action/\"><Number>18217654321</Number></Dial><Dial><Number>15671234567</Number></Dial><DTMF>12345</DTMF><GetDigits action=\"http://www.foo.com/gather_pin/\" method=\"POST\"><Speak voice=\"WOMAN\">Enter PIN number.</Speak></GetDigits><GetInput action=\"http://www.foo.com/gather_feedback\" method=\"GET\"><Speak voice=\"WOMAN\">Tell us more about your experience.</Speak></GetInput><Speak voice=\"WOMAN\">Input not recieved.</Speak><Hangup schedule=\"60\" reason=\"rejected\"/><Speak loop=\"0\" voice=\"WOMAN\">Call will hangup after a min.</Speak><Message src=\"12023222222\" dst=\"15671234567\" type=\"sms\" callbackUrl=\"http://foo.com/sms_status/\" callbackMethod=\"POST\">Hi, message from Plivo.</Message><Play>https://amazonaws.com/Trumpet.mp3</Play><PreAnswer><Speak voice=\"WOMAN\">This call will cost $2 a min.</Speak></PreAnswer><Speak voice=\"WOMAN\">Thanks for dropping by.</Speak><Record action=\"http://foo.com/get_recording/\" startOnDialAnswer=\"true\" redirect=\"false\"/><Dial><Number>15551234567</Number></Dial><Speak voice=\"WOMAN\">Leave message after the beep.</Speak><Record action=\"http://foo.com/get_recording/\" maxLength=\"30\" finishOnKey=\"*\"/><Speak voice=\"WOMAN\">Recording not received.</Speak><Speak voice=\"WOMAN\">Your call is being transferred.</Speak><Redirect>http://foo.com/redirect/</Redirect><Speak loop=\"3\" voice=\"WOMAN\">Go green, go plivo.</Speak><Speak voice=\"WOMAN\">I will wait 7 seconds starting now!</Speak><Wait length=\"7\"/><Speak voice=\"WOMAN\">I just waited 7 seconds.</Speak><Wait length=\"120\" beep=\"true\"/><Play>https://s3.amazonaws.com/abc.mp3</Play><Wait length=\"10\"/><Speak voice=\"WOMAN\">Hello</Speak><Wait length=\"10\" silence=\"true\" minSilence=\"3000\"/><Speak voice=\"WOMAN\">Hello, welcome to the Jungle.</Speak></Response>\n", |
|
| 151 |
+ $output); |
|
| 152 |
+ } |
|
| 153 |
+} |
|
| 0 | 154 |
\ No newline at end of file |