public function testFactorySsml()
 {
     $r = new ReflectionClass(ResponseSpeech::class);
     $p0 = $r->getProperty('type');
     $p1 = $r->getProperty('ssml');
     $p0->setAccessible(true);
     $p1->setAccessible(true);
     $this->somock->shouldReceive('isValid')->once()->andReturn(true);
     $this->somock->shouldReceive('getType')->once()->andReturn(ResponseSpeechSO::TYPE_SSML);
     $this->somock->shouldReceive('getSsml')->once()->andReturn('test ssml');
     $instance = ResponseSpeech::Factory($this->somock);
     $this->assertEquals(ResponseSpeechSO::TYPE_SSML, $p0->getValue($instance));
     $this->assertEquals('test ssml', $p1->getValue($instance));
 }
 public function testWriteToJsonStreamAll()
 {
     $js = new StreamJSON();
     $r = new ReflectionClass(Response::class);
     $speechSO = new ResponseSpeechSO();
     $speechSO->setType(ResponseSpeechSO::TYPE_PLAIN_TEXT);
     $speechSO->setText('speech text');
     $speech = ResponseSpeech::Factory($speechSO);
     $repromptSO = new ResponseSpeechSO();
     $repromptSO->setType(ResponseSpeechSO::TYPE_SSML);
     $repromptSO->setSsml('<p>sample ssml</p>');
     $reprompt = ResponseSpeech::Factory($repromptSO);
     $cardSO = new ResponseCardSO();
     $cardSO->setType(ResponseCardSO::TYPE_SIMPLE);
     $cardSO->setTitle("Sample Title");
     $cardSO->setContent("this is the content");
     $card = ResponseCard::Factory($cardSO);
     /* @var Response */
     $instance = $r->newInstanceWithoutConstructor();
     $p0 = $r->getProperty('version');
     $p1 = $r->getProperty('sessionAttributes');
     $p2 = $r->getProperty('outputSpeech');
     $p3 = $r->getProperty('reprompt');
     $p4 = $r->getProperty('card');
     $p5 = $r->getProperty('endSession');
     $p0->setAccessible(true);
     $p1->setAccessible(true);
     $p2->setAccessible(true);
     $p3->setAccessible(true);
     $p4->setAccessible(true);
     $p5->setAccessible(true);
     $p0->setValue($instance, '1.0');
     $p1->setValue($instance, ["first" => ["a" => 1, "b" => "2"], "second" => ["c" => null, "d" => true]]);
     $p2->setValue($instance, $speech);
     $p3->setValue($instance, $reprompt);
     $p4->setValue($instance, $card);
     $p5->setValue($instance, true);
     $instance->writeToJsonStream($js);
     $this->assertEquals(json_encode(["version" => "1.0", "sessionAttributes" => ["first" => ["a" => 1, "b" => "2"], "second" => ["c" => null, "d" => true]], "response" => ["shouldEndSession" => true, "outputSpeech" => ["type" => ResponseSpeechSO::TYPE_PLAIN_TEXT, "text" => "speech text"], "reprompt" => ["type" => ResponseSpeechSO::TYPE_SSML, "ssml" => "<p>sample ssml</p>"], "card" => ["type" => ResponseCardSO::TYPE_SIMPLE, "title" => "Sample Title", "content" => "this is the content"]]]), (string) $js);
 }
 private function processIntent(SlimEcho\RequestIntent $echoRequest, array $user)
 {
     $speechSO = new SlimEcho\ResponseSpeechSO();
     $slots = $echoRequest->getSlots();
     $noun = $slots['Item']['value'];
     if (isset($slots['Status'])) {
         $status = $slots['Status']['value'];
     } else {
         $status = null;
     }
     if (isset($status)) {
         // updating a status
         $user[$noun] = ['status' => $status, 'since' => date('r')];
         $speechSO->setType($speechSO::TYPE_PLAIN_TEXT);
         $speechSO->setText("I've made a note that the {$noun} are {$status} ");
     } else {
         // reporting on a prior status
         if (!isset($user[$noun])) {
             $speechSO->setType($speechSO::TYPE_PLAIN_TEXT);
             $speechSO->setText("Sorry, I don't seem to have a record of your {$noun} ");
         } else {
             $status = $user[$noun]['status'];
             $speechSO->setType($speechSO::TYPE_PLAIN_TEXT);
             $speechSO->setText("Your {$noun} are {$status} ");
         }
     }
     $speech = SlimEcho\ResponseSpeech::Factory($speechSO);
     $echoResponseSO = new SlimEcho\ResponseSO();
     $echoResponseSO->endSession();
     $echoResponseSO->setOutputSpeech($speech);
     $this->putUserRecord($user);
     return $echoResponseSO;
 }