Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Oct 5, 2017
1 parent a8fe984 commit 677c21a
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions tests/AmazonAlexaDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
use PHPUnit_Framework_TestCase;
use BotMan\BotMan\Messages\Outgoing\Question;
use Symfony\Component\HttpFoundation\Request;
use BotMan\BotMan\Drivers\Events\GenericEvent;
use Symfony\Component\HttpFoundation\Response;
use BotMan\Drivers\AmazonAlexa\AmazonAlexaDriver;
use BotMan\BotMan\Messages\Incoming\IncomingMessage;
use BotMan\BotMan\Messages\Outgoing\OutgoingMessage;
use Symfony\Component\HttpFoundation\Response;

class AmazonAlexaDriverTest extends PHPUnit_Framework_TestCase
{
Expand All @@ -26,7 +27,7 @@ private function getDriver($responseData, $htmlInterface = null)
return new AmazonAlexaDriver($request, [], $htmlInterface);
}

private function getValidDriver($htmlInterface = null)
private function getValidDriver($htmlInterface = null, $type = 'IntentRequest')
{
$responseData = '{
"session": {
Expand All @@ -41,7 +42,7 @@ private function getValidDriver($htmlInterface = null)
}
},
"request": {
"type": "IntentRequest",
"type": "'.$type.'",
"requestId": "request_id",
"intent": {
"name": "intent_name",
Expand Down Expand Up @@ -193,6 +194,25 @@ public function it_can_send_payload()
$this->assertSame('{"version":"1.0","sessionAttributes":[],"response":{"outputSpeech":{"type":"PlainText","text":"string"},"card":null,"reprompt":null,"shouldEndSession":false}}', $response->getContent());
}

/** @test */
public function it_fires_launch_event()
{
$driver = $this->getValidDriver(null, AmazonAlexaDriver::LAUNCH_REQUEST);

$event = $driver->hasMatchingEvent();

$this->assertInstanceOf(GenericEvent::class, $event);
$this->assertSame(AmazonAlexaDriver::LAUNCH_REQUEST, $event->getName());
}

/** @test */
public function it_no_events_for_regular_messages()
{
$driver = $this->getValidDriver();

$this->assertFalse($driver->hasMatchingEvent());
}

/** @test */
public function it_can_get_conversation_answers()
{
Expand Down

0 comments on commit 677c21a

Please sign in to comment.