DirectionTest::testRotatingLeftAndRight()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * (c) 2018 Douglas Reith.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Reith\ToyRobot\Domain\Robot;
11
12
use PHPUnit\Framework\TestCase;
13
14
class DirectionTest extends TestCase
15
{
16
    public static function testGettingDirection()
17
    {
18
        $direction = new Direction();
19
        self::assertInstanceOf(Direction::class, $direction);
20
21
        $compassPosition = $direction->getDirectionAsString();
22
23
        self::assertEquals('E', $compassPosition);
24
    }
25
26
    public static function testRotatingLeftAndRight()
27
    {
28
        $direction = new Direction();
29
        self::assertEquals('E', $direction->getDirectionAsString());
30
31
        // Counter clockwise
32
        $direction->rotateLeft();
33
        self::assertEquals('N', $direction->getDirectionAsString());
34
35
        // Clockwise 180deg
36
        $direction->rotateRight()->rotateRight();
37
        self::assertEquals('S', $direction->getDirectionAsString());
38
39
        $direction->rotateRight() // 'W'
40
            ->rotateLeft() // 'S'
41
            ->rotateLeft() // 'E'
42
            ->rotateLeft() // 'N'
43
            ->rotateLeft(); // 'W'
44
45
        self::assertEquals('W', $direction->getDirectionAsString());
46
    }
47
}
48