Passed
Push — master ( ed42e4...b3b06a )
by Kirill
04:44
created

BaseTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 17
c 1
b 0
f 0
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A getCore() 0 6 1
1
<?php
2
3
/**
4
 * Spiral Framework, SpiralScout LLC.
5
 *
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
9
declare(strict_types=1);
10
11
namespace Spiral\Tests\Console;
12
13
use PHPUnit\Framework\TestCase;
14
use Spiral\Console\Config\ConsoleConfig;
15
use Spiral\Console\Console;
16
use Spiral\Console\LocatorInterface;
17
use Spiral\Console\StaticLocator;
18
use Spiral\Tests\Console\Fixtures\User\UserCommand;
19
use Spiral\Core\Container;
20
21
abstract class BaseTest extends TestCase
22
{
23
    public const TOKENIZER_CONFIG = [
24
        'directories' => [__DIR__ . '/Fixtures/'],
25
        'exclude'     => ['User'],
26
    ];
27
28
    public const CONFIG = [
29
        'locateCommands' => false,
30
        'commands'       => [
31
            UserCommand::class
32
        ]
33
    ];
34
    protected $container;
35
36
    public function setUp(): void
37
    {
38
        $this->container = new Container();
39
40
        $this->container->bind(
41
            ConsoleConfig::class,
42
            new ConsoleConfig(static::CONFIG)
0 ignored issues
show
Bug introduced by
new Spiral\Console\Confi...eConfig(static::CONFIG) of type Spiral\Console\Config\ConsoleConfig is incompatible with the type array|callable|string expected by parameter $resolver of Spiral\Core\Container::bind(). ( Ignorable by Annotation )

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

42
            /** @scrutinizer ignore-type */ new ConsoleConfig(static::CONFIG)
Loading history...
43
        );
44
    }
45
46
    protected function getCore(LocatorInterface $locator = null): Console
47
    {
48
        return new Console(
49
            $this->container->get(ConsoleConfig::class),
50
            $locator ?? new StaticLocator([], $this->container),
51
            $this->container
52
        );
53
    }
54
}
55