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 (#57)
by joseph
16:59
created

AbstractEntitySpecificSaverTest   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 11
dl 0
loc 82
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testRemoveAll() 0 10 2
A testSaveAll() 0 3 1
B setup() 0 22 4
A testSave() 0 3 1
A testRemove() 0 3 1
A getEntitySpecificSaver() 0 8 2
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Savers;
4
5
use EdmondsCommerce\DoctrineStaticMeta\AbstractFunctionalTest;
6
use EdmondsCommerce\DoctrineStaticMeta\AbstractIntegrationTest;
7
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\NamespaceHelper;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\TestEntityGenerator;
9
10
class AbstractEntitySpecificSaverTest extends AbstractFunctionalTest
11
{
12
13
    public const WORK_DIR = AbstractIntegrationTest::VAR_PATH.'/'.self::TEST_TYPE.'/AbstractEntitySpecificSaverTest';
14
15
    private const TEST_ENTITTES = [
16
        self::TEST_PROJECT_ROOT_NAMESPACE.'\\Entities\\TestOne',
17
        self::TEST_PROJECT_ROOT_NAMESPACE.'\\Entities\\Deeply\\Nested\\TestTwo',
18
    ];
19
20
    private $built = false;
21
    /**
22
     * @var EntitySaverFactory
23
     */
24
    private $saverFactory;
25
    /**
26
     * @var array
27
     */
28
    private $generatedEntities;
29
30
    public function setup()
31
    {
32
        parent::setup();
33
        if (true !== $this->built) {
34
            foreach (self::TEST_ENTITTES as $entityFqn) {
35
                $this->getEntityGenerator()->generateEntity($entityFqn, true);
36
            }
37
        }
38
        $this->setupCopiedWorkDirAndCreateDatabase();
39
        $this->saverFactory = new EntitySaverFactory(
40
            $this->getEntityManager(),
41
            new EntitySaver($this->getEntityManager()),
42
            New NamespaceHelper()
43
        );
44
        foreach (self::TEST_ENTITTES as $entityFqn) {
45
            $entityFqn                           = $this->getCopiedFqn($entityFqn);
46
            $this->generatedEntities[$entityFqn] = (new TestEntityGenerator(
47
                100.0,
48
                [],
49
                new \ReflectionClass($entityFqn),
50
                $this->saverFactory
51
            ))->generateEntities($this->getEntityManager(), $entityFqn, 10);
52
        }
53
    }
54
55
    protected function getEntitySpecificSaver(string $entityFqn): AbstractEntitySpecificSaver
56
    {
57
        $saver = $this->saverFactory->getSaverForEntityFqn($entityFqn);
58
        if ($saver instanceof AbstractEntitySpecificSaver) {
59
            return $saver;
60
        }
61
        $this->fail(
62
            '$saver for $entityFqn '.$entityFqn.' is not an instance of AbstractEntitySpecificSaver'
63
        );
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return EdmondsCommerce\Doctrine...ractEntitySpecificSaver. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
64
    }
65
66
    public function testRemoveAll()
67
    {
68
        foreach (self::TEST_ENTITTES as $entityFqn) {
69
            $entityFqn = $this->getCopiedFqn($entityFqn);
70
            $saver     = $this->getEntitySpecificSaver($entityFqn);
71
            $loaded    = $this->getEntityManager()->getRepository($entityFqn)->findAll();
72
            $this->assertSame($this->generatedEntities[$entityFqn], $loaded);
73
            $saver->removeAll($loaded);
74
            $reLoaded = $this->getEntityManager()->getRepository($entityFqn)->findAll();
75
            $this->assertSame([], $reLoaded);
76
        }
77
    }
78
79
    public function testRemove()
80
    {
81
        $this->markTestIncomplete('TODO');
82
    }
83
84
    public function testSaveAll()
85
    {
86
        $this->markTestIncomplete('TODO');
87
    }
88
89
    public function testSave()
90
    {
91
        $this->markTestIncomplete('TODO');
92
    }
93
}
94