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 (#154)
by joseph
26:39
created

InitialiserTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 36
dl 0
loc 86
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setupDbWithFixtures() 0 7 1
A itInitalisesAnEntityThatHasUninitialisedCollections() 0 15 1
A itInitialisesAProxy() 0 15 1
A setUp() 0 8 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\G\Entity\Validation;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\Fixtures\Modifiers\AddAssociationEntitiesModifier;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\Validation\Initialiser;
7
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractLargeTest;
8
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\GetGeneratedCodeContainerTrait;
9
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\TestCodeGenerator;
10
11
/**
12
 * @large
13
 * @covers \EdmondsCommerce\DoctrineStaticMeta\Entity\Validation\Initialiser
14
 */
15
class InitialiserTest extends AbstractLargeTest
16
{
17
    use GetGeneratedCodeContainerTrait;
18
19
    public const WORK_DIR = self::VAR_PATH . '/' . self::TEST_TYPE_MEDIUM . '/InitialiserTest';
20
21
    private const TEST_ENTITY_FQN = self::TEST_ENTITIES_ROOT_NAMESPACE . TestCodeGenerator::TEST_ENTITY_PERSON;
22
    protected static $buildOnce = true;
23
    /**
24
     * @var string
25
     */
26
    private $testEntityFqn;
27
    /**
28
     * @var Initialiser
29
     */
30
    private $initialiser;
31
32
    public function setUp()
33
    {
34
        parent::setUp();
35
        $this->generateTestCode();
36
        $this->setupCopiedWorkDir();
37
        $this->testEntityFqn = $this->getCopiedFqn(self::TEST_ENTITY_FQN);
38
        $this->setupDbWithFixtures();
39
        $this->initialiser = $this->container->get(Initialiser::class);
40
    }
41
42
    /**
43
     * Sets up the DB with the Person Fixture
44
     *
45
     * uses the AddAssociationEntitiesModifier to ensure that the Person objects have the full data
46
     *
47
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
48
     */
49
    private function setupDbWithFixtures(): void
50
    {
51
        $fixturesHelper = $this->getFixturesHelper();
52
        $fixturesHelper->createDb(
53
            $fixturesHelper->createFixture(
54
                $this->getNamespaceHelper()->getFixtureFqnFromEntityFqn($this->testEntityFqn),
55
                new AddAssociationEntitiesModifier($this->getTestEntityGeneratorFactory())
56
            )
57
        );
58
    }
59
60
    /**
61
     * @test
62
     * @large
63
     */
64
    public function itInitialisesAProxy(): void
65
    {
66
        $loaded = $this->getRepositoryFactory()->getRepository($this->testEntityFqn)->findOneBy([]);
67
        /**
68
         * @var \Doctrine\ORM\Proxy\Proxy
69
         */
70
        $attributesAddressProxy = $loaded->getAttributesAddress();
0 ignored issues
show
Bug introduced by
The method getAttributesAddress() does not exist on EdmondsCommerce\Doctrine...erfaces\EntityInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

70
        /** @scrutinizer ignore-call */ 
71
        $attributesAddressProxy = $loaded->getAttributesAddress();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
71
        $expected               = false;
72
        $actual                 = $attributesAddressProxy->__isInitialized__;
73
        self::assertSame($expected, $actual);
74
75
        $this->initialiser->initialise($attributesAddressProxy);
76
        $expected = true;
77
        $actual   = $attributesAddressProxy->__isInitialized__;
78
        self::assertSame($expected, $actual);
79
    }
80
81
82
    /**
83
     * @test
84
     * @large
85
     */
86
    public function itInitalisesAnEntityThatHasUninitialisedCollections(): void
87
    {
88
        $loaded = $this->getRepositoryFactory()->getRepository($this->testEntityFqn)->findOneBy([]);
89
        /**
90
         * @var \Doctrine\ORM\Proxy\Proxy
91
         */
92
        $attributesAddressProxy = $loaded->getAttributesAddress();
93
        $expected               = false;
94
        $actual                 = $attributesAddressProxy->__isInitialized__;
95
        self::assertSame($expected, $actual);
96
97
        $this->initialiser->initialise($loaded);
0 ignored issues
show
Bug introduced by
It seems like $loaded can also be of type null; however, parameter $object of EdmondsCommerce\Doctrine...itialiser::initialise() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

97
        $this->initialiser->initialise(/** @scrutinizer ignore-type */ $loaded);
Loading history...
98
        $expected = true;
99
        $actual   = $attributesAddressProxy->__isInitialized__;
100
        self::assertSame($expected, $actual);
101
    }
102
}
103