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 ( 149ff2...b9f286 )
by Ross
13s
created

EntityGeneratorTest::testGenerateRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Generator;
4
5
use EdmondsCommerce\DoctrineStaticMeta\AbstractTest;
6
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command\AbstractCommand;
7
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\NamespaceHelper;
8
9
class EntityGeneratorTest extends AbstractTest
10
{
11
    public const WORK_DIR = AbstractTest::VAR_PATH.'/EntityGeneratorTest/';
12
13
    /**
14
     */
15
    public function testGenerateEntity()
16
    {
17
        $fqn = static::TEST_PROJECT_ROOT_NAMESPACE
18
               .'\\'.AbstractGenerator::ENTITIES_FOLDER_NAME
19
               .'\\Yet\\Another\\TestEntity';
20
        $this->getEntityGenerator()->generateEntity($fqn);
21
        $createdFile = static::WORK_DIR
22
                       .'/'.AbstractCommand::DEFAULT_SRC_SUBFOLDER
23
                       .'/'.AbstractGenerator::ENTITIES_FOLDER_NAME
24
                       .'/Yet/Another/TestEntity.php';
25
        $this->assertNoMissedReplacements($createdFile);
26
27
        $createdFile = static::WORK_DIR
28
                       .'/'.AbstractCommand::DEFAULT_SRC_SUBFOLDER
29
                       .'/'.AbstractGenerator::ENTITY_REPOSITORIES_FOLDER_NAME
30
                       .'/Yet/Another/TestEntityRepository.php';
31
        $this->assertNoMissedReplacements($createdFile);
32
        $this->qaGeneratedCode();
33
    }
34
35
    public function testGenerateRepository(): void
36
    {
37
        $entityFqn = static::TEST_PROJECT_ROOT_NAMESPACE
38
                     .'\\'.AbstractGenerator::ENTITIES_FOLDER_NAME
39
                     .'\\Some\\Other\\TestEntity';
40
41
        $repositoryFqn = '\\'.static::TEST_PROJECT_ROOT_NAMESPACE
42
                         .AbstractGenerator::ENTITY_REPOSITORIES_NAMESPACE
43
                         .'\\Some\\Other\\TestEntityRepository';
44
45
        $this->getEntityGenerator()->generateEntity($entityFqn);
46
        $this->setupCopiedWorkDir();
47
48
        $entityManager = $this->getEntityManager();
49
        $repository    = $entityManager->getRepository($this->getCopiedFqn($entityFqn));
50
        $this->assertInstanceOf($this->getCopiedFqn($repositoryFqn), $repository);
51
    }
52
53
54
    public function testGenerateEntityWithDeepNesting()
55
    {
56
        $entityNamespace          = static::TEST_PROJECT_ROOT_NAMESPACE.'\\'
57
                                    .AbstractGenerator::ENTITIES_FOLDER_NAME
58
                                    .'\\Human\\Head\\Eye';
59
        $entityFullyQualifiedName = $entityNamespace.'\\Lash';
60
        $this->getEntityGenerator()
61
             ->setProjectRootNamespace(static::TEST_PROJECT_ROOT_NAMESPACE)
62
             ->generateEntity($entityFullyQualifiedName);
63
64
        $createdFile = static::WORK_DIR
65
                       .'/'.AbstractCommand::DEFAULT_SRC_SUBFOLDER
66
                       .'/'.AbstractGenerator::ENTITIES_FOLDER_NAME
67
                       .'/Human/Head/Eye/Lash.php';
68
        $this->assertNoMissedReplacements($createdFile);
69
        $this->assertContains("namespace $entityNamespace;", file_get_contents($createdFile));
70
71
        $createdFile = static::WORK_DIR
72
                       .'/'.AbstractCommand::DEFAULT_SRC_SUBFOLDER
73
                       .'/'.AbstractGenerator::ENTITY_REPOSITORIES_FOLDER_NAME
74
                       .'/Human/Head/Eye/LashRepository.php';
75
        $this->assertNoMissedReplacements($createdFile);
76
        $entityFullyQualifiedName = $this->container->get(NamespaceHelper::class)->tidy(
77
            static::TEST_PROJECT_ROOT_NAMESPACE.'\\'
78
            .AbstractGenerator::ENTITY_REPOSITORIES_NAMESPACE
79
            .'\\Human\\Head\\Eye'
80
        );
81
        $this->assertContains("namespace $entityFullyQualifiedName;", file_get_contents($createdFile));
82
83
        $this->qaGeneratedCode();
84
    }
85
}
86