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.
Passed
Pull Request — master (#42)
by joseph
02:26
created

GenerateFieldMultipleTimesTest::generateField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
eloc 5
nc 1
nop 2
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\CodeGeneration\Command;
9
10
use Doctrine\Common\Util\Inflector;
11
use EdmondsCommerce\DoctrineStaticMeta\AbstractTest;
12
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Generator\AbstractGenerator;
13
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
14
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
15
use Symfony\Component\Console\Tester\CommandTester;
16
17
class GenerateFieldMultipleTimesTest extends AbstractCommandTest
18
{
19
20
    public const WORK_DIR = AbstractTest::VAR_PATH . '/GenerateSameFieldMultipleTime/';
21
    /**
22
     * @var array
23
     */
24
    private $entityName;
25
    /**
26
     * @var CommandTester
27
     */
28
    private $fieldGenerator;
29
30
    /**
31
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
32
     */
33
    public function setup(): void
34
    {
35
        parent::setup();
36
        $this->entityName     = $this->generateEntities();
37
        $generateCommand      = $this->container->get(GenerateFieldCommand::class);
38
        $this->fieldGenerator = $this->getCommandTester($generateCommand);
39
    }
40
41
    public function testItShouldNotBePossibleToGenerateTheSameFieldTwice(): void
42
    {
43
        $type      = MappingHelper::TYPE_STRING;
44
        $fieldName = $this->getNameSpace('should_not_error');
45
        /* Generate the field */
46
        $this->generateField($fieldName, $type);
47
        /* And Again */
48
        $this->expectException(DoctrineStaticMetaException::class);
49
        $this->generateField($fieldName, $type);
50
    }
51
52
    /**
53
     * @param string $fieldName
54
     *
55
     * @return string
56
     * @SuppressWarnings(PHPMD.StaticAccess)
57
     */
58
    private function getNameSpace(string $fieldName): string
59
    {
60
        $classy    = Inflector::classify($fieldName);
61
        $namespace = static::TEST_PROJECT_ROOT_NAMESPACE . AbstractGenerator::ENTITY_FIELD_TRAIT_NAMESPACE;
62
63
        return "$namespace\\$classy\\$classy";
64
    }
65
66
    private function generateField(string $fullyQualifiedName, string $type): void
67
    {
68
        $this->fieldGenerator->execute(
69
            [
70
                '-' . GenerateFieldCommand::OPT_PROJECT_ROOT_PATH_SHORT      => self::WORK_DIR,
71
                '-' . GenerateFieldCommand::OPT_PROJECT_ROOT_NAMESPACE_SHORT => self::TEST_PROJECT_ROOT_NAMESPACE,
72
                '--' . GenerateFieldCommand::OPT_FQN                         => $fullyQualifiedName,
73
                '--' . GenerateFieldCommand::OPT_TYPE                        => $type,
74
            ]
75
        );
76
    }
77
}
78