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 (#196)
by joseph
28:03
created

ImplementNotifyChangeTrackingPolicyTest::setup()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 2
nop 0
dl 0
loc 16
rs 9.8333
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\Entity\Traits;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\DataTransferObjects\AbstractEntityUpdateDto;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Savers\EntitySaverInterface;
8
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
9
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractLargeTest;
10
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\TestCodeGenerator;
11
12
/**
13
 * @large
14
 */
15
class ImplementNotifyChangeTrackingPolicyTest extends AbstractLargeTest
16
{
17
    public const  WORK_DIR   = self::VAR_PATH .
18
                               '/' .
19
                               self::TEST_TYPE_LARGE .
20
                               '/ImplementNotifyChangeTrackingPolicyTest';
21
    private const ENTITY_FQN = self::TEST_ENTITIES_ROOT_NAMESPACE . TestCodeGenerator::TEST_ENTITY_PERSON;
22
    protected static $buildOnce = true;
23
    private          $entity;
24
    /**
25
     * @var string
26
     */
27
    private $entityFqn;
28
    /**
29
     * @var EntitySaverInterface
30
     */
31
    private $saver;
32
    /**
33
     * @var \EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\EntityGenerator\TestEntityGenerator
34
     */
35
    private $testEntityGenerator;
36
37
    public function setup()
38
    {
39
        parent::setUp();
40
        if (false === self::$built) {
41
            $this->getTestCodeGenerator()
42
                 ->copyTo(self::WORK_DIR);
43
            self::$built = true;
44
        }
45
        $this->setupCopiedWorkDirAndCreateDatabase();
46
        $this->entityFqn           = $this->getCopiedFqn(self::ENTITY_FQN);
47
        $this->saver               = $this->getEntitySaver();
48
        $this->testEntityGenerator = $this->getTestEntityGeneratorFactory()
49
                                          ->createForEntityFqn($this->entityFqn);
50
        $this->entity              = $this->testEntityGenerator->generateEntity();
51
        $this->testEntityGenerator->addAssociationEntities($this->entity);
52
        $this->saver->save($this->entity);
53
    }
54
55
    /**
56
     * @test
57
     * @throws DoctrineStaticMetaException
58
     * @throws \ReflectionException
59
     */
60
    public function youCanUpdateWithAnEmptyCollection(): void
61
    {
62
        $dto = new class($this->entityFqn, $this->entity->getId()) extends AbstractEntityUpdateDto
63
        {
64
            public function getAttributesEmails(): ArrayCollection
65
            {
66
                return new ArrayCollection();
67
            }
68
        };
69
        $this->entity->update($dto);
70
        $this->saver->save($this->entity);
71
        $this->getEntityManager()->clear();
72
        $loaded   = $this->getRepositoryFactory()->getRepository($this->entityFqn)->find($this->entity->getId());
73
        $expected = 0;
74
        $actual   = $loaded->getAttributesEmails()->count();
0 ignored issues
show
Bug introduced by
The method getAttributesEmails() 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

74
        $actual   = $loaded->/** @scrutinizer ignore-call */ getAttributesEmails()->count();

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...
75
        self::assertSame($expected, $actual);
76
    }
77
}
78