Passed
Push — master ( 35eebd...7b8a1a )
by Roman
16:45
created

GamePlayTest::testCreateNewGame()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 0
dl 0
loc 34
ccs 0
cts 17
cp 0
crap 2
rs 9.568
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Tests\Game\Features\GamePlay;
6
7
use App\Game\Features\GamePlay\Crossword\CrosswordConstructor;
8
use App\Game\Features\GamePlay\Crossword\CrosswordDto;
9
use App\Game\Features\GamePlay\Crossword\CrosswordInterface;
10
use App\Game\Features\GamePlay\Crossword\GameDto;
11
use App\Game\Features\GamePlay\Crossword\Type;
12
use App\Game\Features\GamePlay\GamePlay;
13
use App\Game\Features\GamePlay\Player\Role;
14
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...
15
use Psr\Log\NullLogger;
0 ignored issues
show
Bug introduced by
The type Psr\Log\NullLogger 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...
16
17
/**
18
 * @coversDefaultClass \App\Game\Features\GamePlay\GamePlay
19
 */
20
final class GamePlayTest extends TestCase
21
{
22
    /**
23
     * @covers ::new
24
     */
25
    public function testCreateNewGame(): void
26
    {
27
        $crossword = new CrosswordDto([
28
            'success' => true,
29
            'data' => [
30
                [
31
                    'line' => [
32
                        ['coordinate' => '1.1', 'letter' => 't'],
33
                        ['coordinate' => '1.2', 'letter' => 'e'],
34
                        ['coordinate' => '1.3', 'letter' => 's'],
35
                        ['coordinate' => '1.4', 'letter' => 't'],
36
                    ],
37
                    'word' => ['definition' => 'test']
38
                ]
39
            ]
40
        ]);
41
42
        $crosswordMock = $this->createMock(CrosswordInterface::class);
43
        $crosswordMock->method('construct')->willReturn($crossword);
44
45
        $gamePlay = new GamePlay(new CrosswordConstructor($crosswordMock, new NullLogger()));
46
        $gameDto = $gamePlay->new(
47
            'en',
48
            Type::byRole(new Role(Role::SIMPLE_PLAYER)),
49
            3 * 2
50
        );
51
52
        self::assertInstanceOf(GameDto::class, $gameDto);
53
        self::assertSame(4, $gameDto->size());
54
        self::assertSame(['test'], $gameDto->definitions());
55
        self::assertSame('t', $gameDto->grid()['1.1']['letter']);
56
        self::assertSame('e', $gameDto->grid()['1.2']['letter']);
57
        self::assertSame('s', $gameDto->grid()['1.3']['letter']);
58
        self::assertSame('t', $gameDto->grid()['1.4']['letter']);
59
    }
60
}
61