|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace App\Tests\Game\Features\Registration\Console; |
|
6
|
|
|
|
|
7
|
|
|
use App\Game\Features\Player\Player\Player; |
|
8
|
|
|
use App\Game\Features\Player\Player\Role; |
|
9
|
|
|
use App\Game\Features\Registration\Console\CreatePlayerCommand; |
|
10
|
|
|
use App\Game\Features\Registration\PlayerRegister; |
|
11
|
|
|
use App\Game\Infrastructure\Repository\InMemory\InMemoryPlayerRepository; |
|
12
|
|
|
use Generator; |
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
|
|
|
|
|
|
15
|
|
|
use Symfony\Component\Console\Output\NullOutput; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @coversDefaultClass \App\Game\Features\Registration\Console\CreatePlayerCommand |
|
19
|
|
|
*/ |
|
20
|
|
|
final class CreatePlayerCommandTest extends TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @covers ::execute |
|
24
|
|
|
* |
|
25
|
|
|
* @dataProvider useRoleDataProvider |
|
26
|
|
|
*/ |
|
27
|
|
|
public function testCreatePlayerWithRole(array $roleOption, Role $role): void |
|
28
|
|
|
{ |
|
29
|
|
|
$data = array_merge(['nickname' => 'test', 'password' => '1q2w3e4r'], $roleOption); |
|
30
|
|
|
$inMemoryPlayerRepository = new InMemoryPlayerRepository(); |
|
31
|
|
|
$command = new CreatePlayerCommand(new PlayerRegister($inMemoryPlayerRepository)); |
|
32
|
|
|
$command->run(new ArrayInput($data), new NullOutput()); |
|
33
|
|
|
|
|
34
|
|
|
self::assertCount(1, $inMemoryPlayerRepository->players()); |
|
35
|
|
|
|
|
36
|
|
|
$players = $inMemoryPlayerRepository->players(); |
|
37
|
|
|
$player = array_shift($players); |
|
38
|
|
|
self::assertInstanceOf(Player::class, $player); |
|
39
|
|
|
self::assertTrue($player->role()->equals($role)); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function useRoleDataProvider(): Generator |
|
43
|
|
|
{ |
|
44
|
|
|
yield 'Simple player by default role' => [[], new Role(Role::SIMPLE_PLAYER)]; |
|
45
|
|
|
yield 'Simple player' => [['--role' => Role::SIMPLE_PLAYER], new Role(Role::SIMPLE_PLAYER)]; |
|
46
|
|
|
yield 'Premium player' => [['--role' => Role::PREMIUM_PLAYER], new Role(Role::PREMIUM_PLAYER)]; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
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