GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( a48bd8...83d092 )
by joseph
16:18 queued 18s
created

GenerateRelationsCommandTest::getCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\E\CodeGeneration\Command;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
use Doctrine\ORM\Tools\Console\ConsoleRunner;
7
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command\AbstractCommand;
8
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command\GenerateEntityCommand;
9
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command\GenerateRelationsCommand;
10
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractTest;
11
use Symfony\Component\Console\Application;
12
use Symfony\Component\Console\Tester\CommandTester;
13
14
/**
15
 * Class GenerateRelationsCommandTest
16
 *
17
 * @package EdmondsCommerce\DoctrineStaticMeta\Tests\Large\CodeGeneration\Command
18
 * @covers  \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command\GenerateRelationsCommand
19
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
20
 */
21
class GenerateRelationsCommandTest extends AbstractTest
22
{
23
    public const WORK_DIR = AbstractTest::VAR_PATH . '/' . self::TEST_TYPE_LARGE . '/GenerateRelationsCommandTest/';
24
25
    private const TEST_ENTITY = self::TEST_ENTITIES_ROOT_NAMESPACE . '\\GenerateRelationsCommandTestEntity';
26
27
    public function setup()
28
    {
29
        parent::setUp();
30
        $this->getEntityGenerator()->generateEntity(self::TEST_ENTITY);
31
    }
32
33
    /**
34
     * @test
35
     * @large
36
     *      * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
37
     * @throws \Psr\Container\ContainerExceptionInterface
38
     * @throws \Psr\Container\NotFoundExceptionInterface
39
     * @throws \ReflectionException
40
     */
41
    public function generateRelationsNoFiltering(): void
42
    {
43
44
        $command = $this->getCommand();
45
        $tester  = $this->getCommandTester($command);
46
        $tester->execute(
47
            [
48
                '-' . GenerateEntityCommand::OPT_PROJECT_ROOT_PATH_SHORT      => self::WORK_DIR,
49
                '-' . GenerateEntityCommand::OPT_PROJECT_ROOT_NAMESPACE_SHORT => self::TEST_PROJECT_ROOT_NAMESPACE,
50
            ]
51
        );
52
        $entityFqn      = self::TEST_ENTITY;
53
        $entityName     = (new  \ts\Reflection\ReflectionClass($entityFqn))->getShortName();
54
        $entityPlural   = ucfirst($entityFqn::getDoctrineStaticMeta()->getPlural());
55
        $createdFiles[] =
0 ignored issues
show
Comprehensibility Best Practice introduced by
$createdFiles was never initialized. Although not strictly required by PHP, it is generally a good practice to add $createdFiles = array(); before regardless.
Loading history...
56
            glob(self::WORK_DIR . '/src/Entity/Relations/' . $entityName . '/Traits/Has' . $entityName . '/*.php');
57
        $createdFiles[] =
58
            glob(self::WORK_DIR . '/src/Entity/Relations/' . $entityName . '/Traits/Has' . $entityPlural . '/*.php');
59
        $createdFiles[] = glob(self::WORK_DIR . '/src/Entity/Relations/' . $entityName . '/Traits/*.php');
60
        $createdFiles   = array_merge(...$createdFiles);
61
        self::assertNotEmpty($createdFiles, 'Failed finding any created files in ' . __METHOD__);
62
        foreach ($createdFiles as $createdFile) {
63
            $this->assertNoMissedReplacements($createdFile);
64
        }
65
    }
66
67
    private function getCommand(): GenerateRelationsCommand
68
    {
69
        return $this->container->get(GenerateRelationsCommand::class);
70
    }
71
72
    /**
73
     * @param AbstractCommand $command
74
     *
75
     * @return CommandTester
76
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
77
     * @SuppressWarnings(PHPMD.StaticAccess)
78
     */
79
    protected function getCommandTester(AbstractCommand $command): CommandTester
80
    {
81
        $application = new Application();
82
        //$_SERVER[ConfigInterface::PARAM_ENTITIES_PATH] = static::WORK_DIR.'/src/Entities';
83
        $helperSet = ConsoleRunner::createHelperSet(
84
            $this->container->get(EntityManagerInterface::class)
85
        );
86
        $application->setHelperSet($helperSet);
87
        $application->add($command);
88
89
        return new CommandTester($command);
90
    }
91
}
92