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
36:20
created

itInitalisesAnEntityThatHasUninitialisedCollections()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 15
rs 9.9666
c 0
b 0
f 0
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
23
    /**
24
     * @var string
25
     */
26
    private $testEntityFqn;
27
28
    /**
29
     * @var Initialiser
30
     */
31
    private $initialiser;
32
33
    public function setUp()
34
    {
35
        parent::setUp();
36
        $this->generateTestCode();
37
        $this->setupCopiedWorkDir();
38
        $this->testEntityFqn = $this->getCopiedFqn(self::TEST_ENTITY_FQN);
39
        $this->setupDbWithFixtures();
40
        $this->initialiser = $this->container->get(Initialiser::class);
41
    }
42
43
    /**
44
     * Sets up the DB with the Person Fixture
45
     *
46
     * uses the AddAssociationEntitiesModifier to ensure that the Person objects have the full data
47
     *
48
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
49
     */
50
    private function setupDbWithFixtures(): void
51
    {
52
        $fixturesHelper = $this->getFixturesHelper();
53
        $fixturesHelper->createDb(
54
            $fixturesHelper->createFixture(
55
                $this->getNamespaceHelper()->getFixtureFqnFromEntityFqn($this->testEntityFqn),
56
                new AddAssociationEntitiesModifier($this->getTestEntityGeneratorFactory())
57
            )
58
        );
59
    }
60
61
    /**
62
     * @test
63
     * @large
64
     */
65
    public function itInitialisesAProxy(): void
66
    {
67
        $loaded = $this->getRepositoryFactory()->getRepository($this->testEntityFqn)->findOneBy([]);
68
        /**
69
         * @var \Doctrine\ORM\Proxy\Proxy
70
         */
71
        $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

71
        /** @scrutinizer ignore-call */ 
72
        $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...
72
        $expected               = false;
73
        $actual                 = $attributesAddressProxy->__isInitialized__;
74
        self::assertSame($expected, $actual);
75
76
        $this->initialiser->initialise($attributesAddressProxy);
77
        $expected = true;
78
        $actual   = $attributesAddressProxy->__isInitialized__;
79
        self::assertSame($expected, $actual);
80
    }
81
82
83
    /**
84
     * @test
85
     * @large
86
     */
87
    public function itInitalisesAnEntityThatHasUninitialisedCollections(): void
88
    {
89
        $loaded = $this->getRepositoryFactory()->getRepository($this->testEntityFqn)->findOneBy([]);
90
        /**
91
         * @var \Doctrine\ORM\Proxy\Proxy
92
         */
93
        $attributesAddressProxy = $loaded->getAttributesAddress();
94
        $expected               = false;
95
        $actual                 = $attributesAddressProxy->__isInitialized__;
96
        self::assertSame($expected, $actual);
97
98
        $this->initialiser->initialise($loaded);
0 ignored issues
show
Bug introduced by
It seems like $loaded can also be of type null; however, parameter $entityOrDto 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

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