Passed
Pull Request — master (#593)
by butschster
05:58
created

LazyTest.php$0 ➔ getScopedClasses()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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 Spiral\Tokenizer\ScopedClassesInterface;
18
use Symfony\Component\Console\Command\LazyCommand;
19
20
class LazyTest extends BaseTest
21
{
22
    public function testLazyCommandCreationInCommandLocator(): void
23
    {
24
        $locator = new CommandLocator(
25
            new class() implements ScopedClassesInterface {
26
                public function getScopedClasses(string $scope, $target = null): array
27
                {
28
                    return [
29
                        new \ReflectionClass(LazyLoadedCommand::class),
30
                    ];
31
                }
32
            },
33
            $this->container
34
        );
35
        $commands = $locator->locateCommands();
36
        $command = reset($commands);
37
38
        $this->assertInstanceOf(LazyCommand::class, $command);
39
        $this->assertSame('lazy', $command->getName());
40
        $this->assertSame('Lazy description', $command->getDescription());
41
    }
42
43
    public function testLazyCommandCreationInStaticLocator(): void
44
    {
45
        $locator = new StaticLocator([LazyLoadedCommand::class]);
46
        $commands = $locator->locateCommands();
47
        $command = reset($commands);
48
49
        $this->assertInstanceOf(LazyCommand::class, $command);
50
        $this->assertSame('lazy', $command->getName());
51
        $this->assertSame('Lazy description', $command->getDescription());
52
    }
53
54
    public function testLazyCommandExecution(): void
55
    {
56
        $core = $this->getCore(new StaticLocator([LazyLoadedCommand::class]));
57
        $output = $core->run('lazy');
58
        $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

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