diff --git a/Makefile b/Makefile index 066f0ac..eeb91b4 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: install update test +.PHONY: install update test clean-coverage install: composer install @@ -9,5 +9,8 @@ update: composer dumpautoload make test -test: - ./vendor/bin/phpunit --testdox \ No newline at end of file +test: clean-coverage + ./vendor/bin/phpunit --testdox + +clean-coverage: + rm -rf ./test/_reports \ No newline at end of file diff --git a/src/Model/Command/TurnLeft.php b/src/Model/Command/TurnLeft.php index b89551d..cad6c79 100644 --- a/src/Model/Command/TurnLeft.php +++ b/src/Model/Command/TurnLeft.php @@ -21,6 +21,9 @@ public function execute(Rover $Rover): void return; } + /** + * @codeCoverageIgnore + */ protected function rotateFrom($currentDirection): string { switch ($currentDirection) { diff --git a/src/Model/Command/TurnRight.php b/src/Model/Command/TurnRight.php index fbd6ef1..6989624 100644 --- a/src/Model/Command/TurnRight.php +++ b/src/Model/Command/TurnRight.php @@ -21,6 +21,9 @@ public function execute(Rover $Rover): void return; } + /** + * @codeCoverageIgnore + */ protected function rotateFrom($currentDirection): string { switch ($currentDirection) { diff --git a/test/Model/Command/TurnLeftTest.php b/test/Model/Command/TurnLeftTest.php index 41c0c29..5f68fa3 100644 --- a/test/Model/Command/TurnLeftTest.php +++ b/test/Model/Command/TurnLeftTest.php @@ -4,7 +4,6 @@ namespace MarsRover\Test\Model\Command; -use MarsRover\Model\Command\CommandsCollection; use MarsRover\Model\Rover\Rover; use MarsRover\Model\Rover\RoverSetup; use MarsRover\Service\CommandFactory; @@ -12,18 +11,14 @@ class TurnLeftTest extends TestCase { - public function testCanTurnCorrectly() + public function testCanTurnLefCorrectly() { - $Move = (new CommandFactory())->createCommand("L"); - $CommandCollection = new CommandsCollection(); - $CommandCollection->append($Move); - $Rover = new Rover(); $Rover->setSetup(new RoverSetup("1 1 S")); - $Rover->setCommands($CommandCollection); - $Rover->execute(); - $this->expectOutputString("1 1 E"); - echo $Rover->getSetupAsString(); + $TurnLeft = (new CommandFactory())->createCommand("L"); + $TurnLeft->execute($Rover); + + $this->assertEquals("E", $Rover->getSetup()->getDirection()->getOrientation()); } } diff --git a/test/Model/Command/TurnRightTest.php b/test/Model/Command/TurnRightTest.php index 4a47078..c175e31 100644 --- a/test/Model/Command/TurnRightTest.php +++ b/test/Model/Command/TurnRightTest.php @@ -4,7 +4,6 @@ namespace MarsRover\Test\Model\Command; -use MarsRover\Model\Command\CommandsCollection; use MarsRover\Model\Rover\Rover; use MarsRover\Model\Rover\RoverSetup; use MarsRover\Service\CommandFactory; @@ -12,18 +11,14 @@ class TurnRightTest extends TestCase { - public function testCanTurnCorrectly() + public function testCanTurnRightCorrectly() { - $Move = (new CommandFactory())->createCommand("R"); - $CommandCollection = new CommandsCollection(); - $CommandCollection->append($Move); - $Rover = new Rover(); $Rover->setSetup(new RoverSetup("1 1 S")); - $Rover->setCommands($CommandCollection); - $Rover->execute(); - $this->expectOutputString("1 1 W"); - echo $Rover->getSetupAsString(); + $TurnLeft = (new CommandFactory())->createCommand("R"); + $TurnLeft->execute($Rover); + + $this->assertEquals("W", $Rover->getSetup()->getDirection()->getOrientation()); } }