Skip to content

Commit

Permalink
Resolve #28 Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbeckers committed Jun 30, 2018
1 parent 0042321 commit ab0d991
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ class SetLightDirective extends Directive
{
const TYPE = 'GadgetController.SetLight';

/**
* @var int|null
*/
public $version;

/**
* @var array
*/
Expand All @@ -24,16 +29,18 @@ class SetLightDirective extends Directive
/**
* @param array $targetGadgets
* @param Parameters|null $parameters
* @param int $version
*
* @return SetLightDirective
*/
public static function create(array $targetGadgets = [], Parameters $parameters = null): self
public static function create(array $targetGadgets = [], Parameters $parameters = null, int $version = 1): self
{
$setLight = new self();

$setLight->type = self::TYPE;
$setLight->targetGadgets = $targetGadgets;
$setLight->parameters = $parameters;
$setLight->version = $version;

return $setLight;
}
Expand Down
25 changes: 25 additions & 0 deletions test/Tests/Response/Directives/GadgetControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use MaxBeckers\AmazonAlexa\Response\Directives\GadgetController\Animations;
use MaxBeckers\AmazonAlexa\Response\Directives\GadgetController\Parameters;
use MaxBeckers\AmazonAlexa\Response\Directives\GadgetController\Sequence;
use MaxBeckers\AmazonAlexa\Response\Directives\GadgetController\SetLightDirective;
use PHPUnit\Framework\TestCase;

/**
* @author Maximilian Beckers <beckers.maximilian@gmail.com>
*/
class GadgetControllerTest extends TestCase
{
public function testSetLightDirective()
{
$sequence = Sequence::create(100, 'FF0099');
$animations = Animations::create(10, ['1'], [$sequence]);
$parameters = Parameters::create(Parameters::TRIGGER_EVENT_BUTTON_DOWN, 10, $animations);

$sl = SetLightDirective::create(['gadgetId1', 'gadgetId2'], $parameters);
$this->assertSame('GadgetController.SetLight', $sl->type);
$this->assertSame(1, $sl->version);
$this->assertSame(100, $sl->parameters->animations->sequence[0]->durationMs);
}
}

0 comments on commit ab0d991

Please sign in to comment.