Passed
Push — master ( 1fb483...35eebd )
by Roman
04:31
created

CellTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 61
ccs 0
cts 30
cp 0
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testCellIsEmpty() 0 7 1
A testCoordinateIsJsonSerialized() 0 8 1
A testCellIsLetter() 0 7 1
A testCellIsBlack() 0 7 1
A testCellFillLetter() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Tests\Crossword\Features\Constructor\Scaner\Grid;
6
7
use App\Crossword\Features\Constructor\Scanner\Grid\Cell;
8
use App\Crossword\Features\Constructor\Scanner\Grid\Coordinate;
9
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
/**
12
 * @coversDefaultClass \App\Crossword\Features\Constructor\Scanner\Grid\Cell
13
 */
14
final class CellTest extends TestCase
15
{
16
    /**
17
     * @covers ::letter
18
     */
19
    public function testCellFillLetter(): void
20
    {
21
        $cell = new Cell(new Coordinate(1, 1), null);
0 ignored issues
show
Bug introduced by
null of type null is incompatible with the type App\Crossword\Features\C...canner\Grid\null|string expected by parameter $letter of App\Crossword\Features\C...rid\Cell::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

21
        $cell = new Cell(new Coordinate(1, 1), /** @scrutinizer ignore-type */ null);
Loading history...
22
        self::assertNull($cell->letter());
23
24
        $cell = Cell::withLetter($cell, 'a');
25
        self::assertSame('a', $cell->letter());
26
    }
27
28
    /**
29
     * @covers ::isLetter
30
     */
31
    public function testCellIsLetter(): void
32
    {
33
        $cell = new Cell(new Coordinate(1, 1), 'a');
34
35
        self::assertTrue($cell->isLetter());
36
        self::assertFalse($cell->isEmpty());
37
        self::assertFalse($cell->isBlack());
38
    }
39
40
    /**
41
     * @covers ::isBlack
42
     */
43
    public function testCellIsBlack(): void
44
    {
45
        $cell = new Cell(new Coordinate(1, 1), '');
46
47
        self::assertTrue($cell->isBlack());
48
        self::assertFalse($cell->isLetter());
49
        self::assertFalse($cell->isEmpty());
50
    }
51
52
    /**
53
     * @covers ::isEmpty
54
     */
55
    public function testCellIsEmpty(): void
56
    {
57
        $cell = new Cell(new Coordinate(1, 1), null);
0 ignored issues
show
Bug introduced by
null of type null is incompatible with the type App\Crossword\Features\C...canner\Grid\null|string expected by parameter $letter of App\Crossword\Features\C...rid\Cell::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

57
        $cell = new Cell(new Coordinate(1, 1), /** @scrutinizer ignore-type */ null);
Loading history...
58
59
        self::assertFalse($cell->isBlack());
60
        self::assertFalse($cell->isLetter());
61
        self::assertTrue($cell->isEmpty());
62
    }
63
64
    /**
65
     * @covers ::coordinate
66
     */
67
    public function testCoordinateIsJsonSerialized(): void
68
    {
69
        $cell = new Cell(new Coordinate(1, 2), null);
0 ignored issues
show
Bug introduced by
null of type null is incompatible with the type App\Crossword\Features\C...canner\Grid\null|string expected by parameter $letter of App\Crossword\Features\C...rid\Cell::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

69
        $cell = new Cell(new Coordinate(1, 2), /** @scrutinizer ignore-type */ null);
Loading history...
70
        $coordinate = $cell->coordinate()->jsonSerialize();
71
72
        self::assertInstanceOf(Coordinate::class, $cell->coordinate());
73
        self::assertSame(1, $coordinate['x']);
74
        self::assertSame(2, $coordinate['y']);
75
    }
76
}
77