Completed
Push — master ( af3c22...fbabbd )
by Douglas
01:45
created

DirectionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGettingDirection() 0 9 1
A testRotatingLeftAndRight() 0 21 1
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