Passed
Push — master ( 04a567...992e53 )
by Kirill
05:40 queued 19s
created

LazyTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 4

7 Methods

Rating   Name   Duplication   Size   Complexity  
testLazyCommandExecution() 0 5 ?
testLazyCommandCreationInStaticLocator() 0 9 ?
testLazyCommandCreationInCommandLocator() 0 19 ?
A hp$0 ➔ testLazyCommandExecution() 0 5 1
A hp$0 ➔ testLazyCommandCreationInCommandLocator() 0 19 1
A hp$0 ➔ testLazyCommandCreationInStaticLocator() 0 9 1
A hp$0 ➔ getClasses() 0 4 1
1
<?php
2
3
/**
4
 * Spiral Framework, SpiralScout LLC.
5
 *
6
 * @author    Vladislav Gorenkin (vladgorenkin)
7
 */
8
9
declare(strict_types=1);
10
11
namespace Spiral\Tests\Console;
12
13
use Spiral\Console\CommandLocator;
14
use Spiral\Console\StaticLocator;
15
use Spiral\Tests\Console\Fixtures\LazyLoadedCommand;
16
use Spiral\Tokenizer\ClassesInterface;
17
use Symfony\Component\Console\Command\LazyCommand;
18
19
class LazyTest extends BaseTest
20
{
21
    public function testLazyCommandCreationInCommandLocator(): void
22
    {
23
        $locator = new CommandLocator(
24
            new class() implements ClassesInterface {
25
                public function getClasses($target = null): array
26
                {
27
                    return [
28
                        new \ReflectionClass(LazyLoadedCommand::class),
29
                    ];
30
                }
31
            },
32
            $this->container
33
        );
34
        $commands = $locator->locateCommands();
35
        $command = reset($commands);
36
37
        $this->assertInstanceOf(LazyCommand::class, $command);
38
        $this->assertSame('lazy', $command->getName());
39
        $this->assertSame('Lazy description', $command->getDescription());
40
    }
41
42
    public function testLazyCommandCreationInStaticLocator(): void
43
    {
44
        $locator = new StaticLocator([LazyLoadedCommand::class]);
45
        $commands = $locator->locateCommands();
46
        $command = reset($commands);
47
48
        $this->assertInstanceOf(LazyCommand::class, $command);
49
        $this->assertSame('lazy', $command->getName());
50
        $this->assertSame('Lazy description', $command->getDescription());
51
    }
52
53
    public function testLazyCommandExecution(): void
54
    {
55
        $core = $this->getCore(new StaticLocator([LazyLoadedCommand::class]));
56
        $output = $core->run('lazy');
57
        $this->assertSame('OK', $output->getOutput()->fetch());
0 ignored issues
show
Bug introduced by
The method fetch() does not exist on Symfony\Component\Console\Output\OutputInterface. It seems like you code against a sub-type of Symfony\Component\Console\Output\OutputInterface such as Symfony\Component\Console\Output\BufferedOutput or Symfony\Component\Consol...put\TrimmedBufferOutput. ( Ignorable by Annotation )

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

57
        $this->assertSame('OK', $output->getOutput()->/** @scrutinizer ignore-call */ fetch());
Loading history...
58
    }
59
}
60