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
Pull Request — master (#101)
by joseph
18:59
created

GenerateFieldMultipleTimesTest::setup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
/**
3
 * @category EdmondsCommerce
4
 * @package  EdmondsCommerce_
5
 * @author   Ross Mitchell <[email protected]>
6
 */
7
8
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\CodeGeneration\Command;
9
10
use Doctrine\Common\Inflector\Inflector;
11
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command\GenerateFieldCommand;
12
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Generator\AbstractGenerator;
13
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
14
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
15
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractTest;
16
use Symfony\Component\Console\Tester\CommandTester;
17
18
/**
19
 * Class GenerateFieldMultipleTimesTest
20
 *
21
 * @package EdmondsCommerce\DoctrineStaticMeta\Tests\Large\CodeGeneration\Command
22
 * @coversDefaultClass \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command\GenerateFieldCommand
23
 */
24
class GenerateFieldMultipleTimesTest extends AbstractCommandTest
25
{
26
27
    public const WORK_DIR = AbstractTest::VAR_PATH .
28
                            '/' .
29
                            self::TEST_TYPE_LARGE .
30
                            '/GenerateSameFieldMultipleTime/';
31
    /**
32
     * @var array
33
     */
34
    private $entityName;
35
    /**
36
     * @var CommandTester
37
     */
38
    private $fieldGenerator;
39
40
    /**
41
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
42
     */
43
    public function setup(): void
44
    {
45
        parent::setup();
46
        $this->entityName     = $this->generateEntities();
47
        $generateCommand      = $this->container->get(GenerateFieldCommand::class);
48
        $this->fieldGenerator = $this->getCommandTester($generateCommand);
49
    }
50
51
    /**
52
     * @test
53
     * @large
54
     * @covers ::execute
55
     */
56
    public function itShouldNotBePossibleToGenerateTheSameFieldTwice(): void
57
    {
58
        $type      = MappingHelper::TYPE_STRING;
59
        $fieldName = $this->getNameSpace('should_not_error');
60
        /* Generate the field */
61
        $this->generateField($fieldName, $type);
62
        /* And Again */
63
        $this->expectException(DoctrineStaticMetaException::class);
64
        $this->generateField($fieldName, $type);
65
    }
66
67
    /**
68
     * @param string $fieldName
69
     *
70
     * @return string
71
     * @SuppressWarnings(PHPMD.StaticAccess)
72
     */
73
    private function getNameSpace(string $fieldName): string
74
    {
75
        $classy    = Inflector::classify($fieldName);
76
        $namespace = static::TEST_PROJECT_ROOT_NAMESPACE . AbstractGenerator::ENTITY_FIELD_TRAIT_NAMESPACE;
77
78
        return "$namespace\\$classy\\$classy";
79
    }
80
81
    private function generateField(string $fullyQualifiedName, string $type): void
82
    {
83
        $this->fieldGenerator->execute(
84
            [
85
                '-' . GenerateFieldCommand::OPT_PROJECT_ROOT_PATH_SHORT      => self::WORK_DIR,
86
                '-' . GenerateFieldCommand::OPT_PROJECT_ROOT_NAMESPACE_SHORT => self::TEST_PROJECT_ROOT_NAMESPACE,
87
                '--' . GenerateFieldCommand::OPT_FQN                         => $fullyQualifiedName,
88
                '--' . GenerateFieldCommand::OPT_TYPE                        => $type,
89
            ]
90
        );
91
    }
92
}
93