@@ -135,6 +135,26 @@ public function testCreatePostCall($payload, $method)
135135 $ this ->assertInstanceOf ('Nexmo\Call\Call ' , $ call );
136136 $ this ->assertEquals ('e46fd8bd-504d-4044-9600-26dd18b41111 ' , $ call ->getId ());
137137 }
138+
139+ /**
140+ * @dataProvider postCallNcco
141+ */
142+ public function testCreatePostCallNcco ($ payload )
143+ {
144+ $ this ->nexmoClient ->send (Argument::that (function (RequestInterface $ request ) use ($ payload ){
145+ $ ncco = [['action ' => 'talk ' , 'text ' => 'Hello World ' ]];
146+
147+ $ this ->assertRequestUrl ('api.nexmo.com ' , '/v1/calls ' , 'POST ' , $ request );
148+ $ this ->assertRequestBodyIsJson (json_encode ($ payload ), $ request );
149+ $ this ->assertRequestJsonBodyContains ('ncco ' , $ ncco , $ request );
150+ return true ;
151+ }))->willReturn ($ this ->getResponse ('created ' , '201 ' ));
152+
153+ $ call = $ this ->collection ->post ($ payload );
154+
155+ $ this ->assertInstanceOf ('Nexmo\Call\Call ' , $ call );
156+ $ this ->assertEquals ('e46fd8bd-504d-4044-9600-26dd18b41111 ' , $ call ->getId ());
157+ }
138158
139159 /**
140160 * @dataProvider postCall
@@ -228,6 +248,45 @@ public function getCall()
228248 ];
229249 }
230250
251+ /**
252+ * Creating a call with an NCCO can take a Call object or a simple array.
253+ * @return array
254+ */
255+ public function postCallNcco ()
256+ {
257+ $ raw = [
258+ 'to ' => [[
259+ 'type ' => 'phone ' ,
260+ 'number ' => '14843331234 '
261+ ]],
262+ 'from ' => [
263+ 'type ' => 'phone ' ,
264+ 'number ' => '14843335555 '
265+ ],
266+ 'ncco ' => [
267+ [
268+ 'action ' => 'talk ' ,
269+ 'text ' => 'Hello World '
270+ ]
271+ ]
272+ ];
273+
274+
275+ $ call = new Call ();
276+ $ call ->setTo ('14843331234 ' )
277+ ->setFrom ('14843335555 ' )
278+ ->setNcco ([
279+ [
280+ 'action ' => 'talk ' ,
281+ 'text ' => 'Hello World '
282+ ]
283+ ]);
284+
285+ return [
286+ 'object ' => [clone $ call ],
287+ 'array ' => [$ raw ]
288+ ];
289+ }
231290 /**
232291 * Creating a call can take a Call object or a simple array.
233292 * @return array
0 commit comments