TableTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreatingATable() 0 7 1
A testThatMovementsMustBeOfTheSameDimensionality() 0 9 1
A getVectorsNotFitForATable() 0 8 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\Space;
11
12
use MathPHP\LinearAlgebra\Vector;
13
use PHPUnit\Framework\TestCase;
14
15
class TableTest extends TestCase
16
{
17
    public static function testCreatingATable()
18
    {
19
        // For a 10 x 10 table, for example
20
        $table = Table::create(10);
21
22
        self::assertInstanceOf(Table::class, $table);
23
    }
24
25
    /**
26
     * When moving in a space, the dimensions of the move must
27
     * be the same dimensionality as the space (in this model).
28
     *
29
     * @dataProvider getVectorsNotFitForATable
30
     * @expectedException \Reith\ToyRobot\Domain\Space\Exception\PlaceDimensionsDoNotMatchSpaceException
31
     */
32
    public static function testThatMovementsMustBeOfTheSameDimensionality(Vector $badPlace)
33
    {
34
        $table = Table::create(5);
35
        self::assertInstanceOf(Table::class, $table);
36
37
        // If we just pass one Vector to move() $from
38
        // is assumed to be origin
39
        $table->move($badPlace);
40
    }
41
42
    public static function getVectorsNotFitForATable(): array
43
    {
44
        return [
45
            [new Vector([1])],
46
            [new Vector([1, 1, 1])],
47
            [new Vector([1, 1, 1, 1])],
48
        ];
49
    }
50
}
51