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

GameTestCase::messageBusMockWithConsecutive()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 2
dl 0
loc 22
ccs 0
cts 12
cp 0
crap 6
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Tests\Game;
6
7
use App\Game\Features\Player\Player\Player;
8
use App\Game\Features\Player\Player\PlayerId;
9
use App\Game\Features\Player\Player\Role;
10
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\MockObject\Rule\InvocationOrder 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...
11
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...
12
use Symfony\Component\Messenger\Envelope;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Messenger\Envelope 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...
13
use Symfony\Component\Messenger\MessageBusInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Messenger\MessageBusInterface 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...
14
15
abstract class GameTestCase extends TestCase
16
{
17
    public function createPlayer(PlayerId $playerId): Player
18
    {
19
        $player = new Player($playerId);
20
        $player->changeNickname('test');
21
        $player->changePassword('1q2w3e4r');
22
        $player->changeLevel(3);
23
        $player->changeRole(new Role(Role::SIMPLE_PLAYER));
24
25
        return $player;
26
    }
27
28
    protected function messageBusMockWithConsecutive(
29
        InvocationOrder $invocationRule,
30
        $message = null
31
    ): MessageBusInterface {
32
        if (null === $message) {
33
            $messageBus = $this->createMock(MessageBusInterface::class);
34
            $messageBus->expects($invocationRule)->method('dispatch');
35
36
            return $messageBus;
37
        }
38
39
        $messageBus = $this->createMock(MessageBusInterface::class);
40
        $messageBus->expects($invocationRule)
41
            ->method('dispatch')
42
            ->withConsecutive(
43
                [
44
                    self::isInstanceOf(get_class($message)),
45
                ]
46
            )
47
            ->willReturn(new Envelope($message));
48
49
        return $messageBus;
50
    }
51
}
52