diff --git a/module/Hello/src/Intent/HelloIntent.php b/module/Hello/src/Intent/HelloIntent.php index 5c10d23..5928562 100644 --- a/module/Hello/src/Intent/HelloIntent.php +++ b/module/Hello/src/Intent/HelloIntent.php @@ -25,21 +25,19 @@ class HelloIntent extends AbstractIntent const NAME = 'HelloIntent'; /** - * @param string $smallImageUrl - * @param string $largeImageUrl - * * @return AlexaResponse */ - public function handle( - string $smallImageUrl, - string $largeImageUrl - ): AlexaResponse { + public function handle(): AlexaResponse + { $sessionContainer = $this->getAlexaResponse()->getSessionContainer(); $count = $sessionContainer->getAttribute('count') + 1; $sessionContainer->setAttribute('count', $count); + $smallImageUrl = $this->getSkillConfiguration()->getSmallImageUrl(); + $largeImageUrl = $this->getSkillConfiguration()->getLargeImageUrl(); + $title = $this->getTextHelper()->getHelloTitle(); $message = $this->getTextHelper()->getHelloMessage() . ' (' . $count . ')'; diff --git a/module/Hello/test/Intent/HelloIntentTest.php b/module/Hello/test/Intent/HelloIntentTest.php index 403c006..a4d55e0 100644 --- a/module/Hello/test/Intent/HelloIntentTest.php +++ b/module/Hello/test/Intent/HelloIntentTest.php @@ -12,6 +12,7 @@ use Hello\Intent\HelloIntent; use PHPUnit\Framework\TestCase; +use TravelloAlexaLibrary\Configuration\SkillConfiguration; use TravelloAlexaLibrary\Intent\AbstractIntent; use TravelloAlexaLibrary\Intent\IntentInterface; use TravelloAlexaLibrary\Request\RequestType\RequestTypeFactory; @@ -50,11 +51,12 @@ public function testInstantiation() ], ]; - $alexaRequest = RequestTypeFactory::createFromData(json_encode($data)); - $alexaResponse = new AlexaResponse(); - $textHelper = new TextHelper(); + $alexaRequest = RequestTypeFactory::createFromData(json_encode($data)); + $alexaResponse = new AlexaResponse(); + $textHelper = new TextHelper(); + $skillConfiguration = new SkillConfiguration(); - $helloIntent = new HelloIntent($alexaRequest, $alexaResponse, $textHelper); + $helloIntent = new HelloIntent($alexaRequest, $alexaResponse, $textHelper, $skillConfiguration); $this->assertTrue($helloIntent instanceof AbstractIntent); $this->assertTrue($helloIntent instanceof IntentInterface); @@ -94,16 +96,18 @@ public function testHandle() $sessionContainer = new SessionContainer(['foo' => 'bar', 'count' => 17,]); - $alexaRequest = RequestTypeFactory::createFromData(json_encode($data)); - $textHelper = new TextHelper(); + $alexaRequest = RequestTypeFactory::createFromData(json_encode($data)); + $textHelper = new TextHelper(); + $alexaResponse = new AlexaResponse(); $alexaResponse->setSessionContainer($sessionContainer); - $smallImageUrl = 'https://image.server/small.png'; - $largeImageUrl = 'https://image.server/large.png'; + $skillConfiguration = new SkillConfiguration(); + $skillConfiguration->setSmallImageUrl('https://image.server/small.png'); + $skillConfiguration->setLargeImageUrl('https://image.server/large.png'); - $helloIntent = new HelloIntent($alexaRequest, $alexaResponse, $textHelper); - $helloIntent->handle($smallImageUrl, $largeImageUrl); + $helloIntent = new HelloIntent($alexaRequest, $alexaResponse, $textHelper, $skillConfiguration); + $helloIntent->handle(); $expected = [ 'version' => '1.0',