|
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\Exception\WordNotFitException; |
|
8
|
|
|
use App\Crossword\Features\Constructor\Scanner\Grid\Cell; |
|
9
|
|
|
use App\Crossword\Features\Constructor\Scanner\Grid\Coordinate; |
|
10
|
|
|
use App\Crossword\Features\Constructor\Scanner\Grid\Line; |
|
11
|
|
|
use App\Crossword\Features\Constructor\Scanner\Grid\Row; |
|
12
|
|
|
use Generator; |
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @coversDefaultClass \App\Crossword\Features\Constructor\Scanner\Grid\Line |
|
17
|
|
|
*/ |
|
18
|
|
|
final class LineTest extends TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @covers ::withLetter |
|
22
|
|
|
*/ |
|
23
|
|
|
public function testFillLetter(): void |
|
24
|
|
|
{ |
|
25
|
|
|
$row = new Row(new Cell(new Coordinate(1, 1), null)); |
|
|
|
|
|
|
26
|
|
|
$line = Line::withLetter($row, 'q'); |
|
27
|
|
|
$cells = $line->jsonSerialize(); |
|
28
|
|
|
|
|
29
|
|
|
self::assertSame($cells[0]['letter'], 'q'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @covers ::withWord |
|
34
|
|
|
*/ |
|
35
|
|
|
public function testThrowException(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$this->expectException(WordNotFitException::class); |
|
38
|
|
|
|
|
39
|
|
|
$row = new Row( |
|
40
|
|
|
new Cell(new Coordinate(1, 1), null), |
|
|
|
|
|
|
41
|
|
|
new Cell(new Coordinate(1, 2), null), |
|
42
|
|
|
new Cell(new Coordinate(1, 3), null), |
|
43
|
|
|
new Cell(new Coordinate(1, 4), 'r'), |
|
44
|
|
|
new Cell(new Coordinate(1, 5), null), |
|
45
|
|
|
new Cell(new Coordinate(1, 6), null), |
|
46
|
|
|
new Cell(new Coordinate(1, 7), null), |
|
47
|
|
|
); |
|
48
|
|
|
|
|
49
|
|
|
Line::withWord($row, 'rest'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @covers ::withWord |
|
54
|
|
|
* |
|
55
|
|
|
* @dataProvider rowDataProvider |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testFillWord(Row $row): void |
|
58
|
|
|
{ |
|
59
|
|
|
$line = Line::withWord($row, 'rest'); |
|
60
|
|
|
$cells = $line->jsonSerialize(); |
|
61
|
|
|
|
|
62
|
|
|
self::assertSame($cells[0]['letter'], 'r'); |
|
63
|
|
|
self::assertSame($cells[1]['letter'], 'e'); |
|
64
|
|
|
self::assertSame($cells[2]['letter'], 's'); |
|
65
|
|
|
self::assertSame($cells[3]['letter'], 't'); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function rowDataProvider(): Generator |
|
69
|
|
|
{ |
|
70
|
|
|
yield '..r.' => [ |
|
71
|
|
|
new Row( |
|
72
|
|
|
new Cell(new Coordinate(1, 1), null), |
|
|
|
|
|
|
73
|
|
|
new Cell(new Coordinate(1, 2), null), |
|
74
|
|
|
new Cell(new Coordinate(1, 3), 'r'), |
|
75
|
|
|
new Cell(new Coordinate(1, 4), null), |
|
76
|
|
|
new Cell(new Coordinate(1, 5), null), |
|
77
|
|
|
new Cell(new Coordinate(1, 6), null), |
|
78
|
|
|
) |
|
79
|
|
|
]; |
|
80
|
|
|
|
|
81
|
|
|
yield '.r..' => [ |
|
82
|
|
|
new Row( |
|
83
|
|
|
new Cell(new Coordinate(1, 1), null), |
|
84
|
|
|
new Cell(new Coordinate(1, 2), 'r'), |
|
85
|
|
|
new Cell(new Coordinate(1, 3), null), |
|
86
|
|
|
new Cell(new Coordinate(1, 4), null), |
|
87
|
|
|
new Cell(new Coordinate(1, 5), null), |
|
88
|
|
|
) |
|
89
|
|
|
]; |
|
90
|
|
|
|
|
91
|
|
|
yield 'r...' => [ |
|
92
|
|
|
new Row( |
|
93
|
|
|
new Cell(new Coordinate(1, 1), 'r'), |
|
94
|
|
|
new Cell(new Coordinate(1, 2), null), |
|
95
|
|
|
new Cell(new Coordinate(1, 3), null), |
|
96
|
|
|
new Cell(new Coordinate(1, 4), null), |
|
97
|
|
|
) |
|
98
|
|
|
]; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths