Completed
Push — master ( 7fbbb0...53f538 )
by Oleg
03:37
created

AddTestCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 34
rs 10
c 0
b 0
f 0
ccs 0
cts 16
cp 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 16 1
A configure() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration\Command\Tests\Api;
5
6
use SlayerBirden\DFCodeGeneration\Command\AbstractApiCommand;
7
use SlayerBirden\DFCodeGeneration\Generator\Controllers\Providers\Decorators\UniqueProviderDecorator;
8
use SlayerBirden\DFCodeGeneration\Generator\DataProvider\BaseProvider;
9
use SlayerBirden\DFCodeGeneration\Generator\DataProvider\CachedProvider;
10
use SlayerBirden\DFCodeGeneration\Generator\DataProvider\DecoratedProvider;
11
use SlayerBirden\DFCodeGeneration\Generator\Tests\Api\AddGenerator;
12
use SlayerBirden\DFCodeGeneration\Generator\Tests\Api\Providers\Decorators\EntityDataDecorator;
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
16
final class AddTestCommand extends AbstractApiCommand
17
{
18
    protected function configure()
19
    {
20
        parent::configure();
21
        $this->setName('generate:test:api:add')
22
            ->setDescription('Add Api Test for add action.')
23
            ->setHelp('This command creates the Codeception Api Test for Add Action for given entity.');
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     * @param InputInterface $input
29
     * @param OutputInterface $output
30
     * @throws \Twig_Error_Loader
31
     * @throws \Twig_Error_Runtime
32
     * @throws \Twig_Error_Syntax
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $baseProvider = new BaseProvider($this->entityClassName);
37
38
        $generator = new AddGenerator(
39
            new CachedProvider(
40
                new DecoratedProvider(
41
                    $baseProvider,
42
                    new UniqueProviderDecorator($this->entityClassName),
43
                    new EntityDataDecorator($this->entityClassName)
44
                )
45
            )
46
        );
47
        $this->writer->write($generator->generate(), $generator->getFileName());
0 ignored issues
show
Bug introduced by
The method write() does not exist on null. ( Ignorable by Annotation )

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

47
        $this->writer->/** @scrutinizer ignore-call */ 
48
                       write($generator->generate(), $generator->getFileName());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
49
        parent::execute($input, $output);
50
    }
51
}
52