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.

EventArgsProvider.php$0 ➔ trigger()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox;
6
7
use Doctrine\ORM\Event\OnFlushEventArgs;
8
use Dsantang\DomainEvents\DeletionAware;
9
use Dsantang\DomainEvents\DomainEvent;
10
use Dsantang\DomainEvents\EventAware;
11
use Dsantang\DomainEvents\Registry\OrderedEventRegistry;
12
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\DeletionEvent;
13
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\FirstDomainEvent;
14
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\SecondDomainEvent;
15
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\ThirdDomainEvent;
16
use PHPUnit\Framework\MockObject\MockObject;
17
18
trait EventArgsProvider
19
{
20
    /** @var MockObject entityManager */
21
    private MockObject $entityManager;
22
23
    /** @var MockObject unitOfWork */
24
    private MockObject $unitOfWork;
25
26
    /**
27
     * @return OnFlushEventArgs|MockObject
28
     */
29
    private function getEventArgs(bool $withEvents = true): OnFlushEventArgs
30
    {
31
        $insertions = $updates = $deletions = [];
32
33
        if ($withEvents) {
34
            $entity1 = new class () implements EventAware {
35
                use OrderedEventRegistry;
36
37
                public function trigger(DomainEvent $event): void
38
                {
39
                    $this->triggeredA($event);
40
                }
41
            };
42
43
            $entity2 = new class () implements EventAware {
44
                use OrderedEventRegistry;
45
46
                public function trigger(DomainEvent $event): void
47
                {
48
                    $this->triggeredA($event);
49
                }
50
            };
51
52
            $entity3 = new class () implements EventAware {
53
                use OrderedEventRegistry;
54
55
                public function trigger(DomainEvent $event): void
56
                {
57
                    $this->triggeredA($event);
58
                }
59
            };
60
61
            $entity4 = new class () implements DeletionAware {
62
                use OrderedEventRegistry;
63
64
                public function expelDeletionEvents(): DomainEvent
65
                {
66
                    return new DeletionEvent();
67
                }
68
            };
69
70
            $domainEvent1 = new FirstDomainEvent();
71
            $domainEvent2 = new SecondDomainEvent();
72
            $domainEvent3 = new ThirdDomainEvent();
73
74
            $entity1->trigger($domainEvent1);
75
            $entity2->trigger($domainEvent2);
76
            $entity3->trigger($domainEvent3);
77
78
            $updates   = [$entity3];
79
            $deletions = [$entity2, $entity1, $entity4];
80
        }
81
82
        $this->unitOfWork->expects(self::any())->method('getScheduledEntityInsertions')->willReturn($insertions);
83
        $this->unitOfWork->expects(self::any())->method('getScheduledEntityUpdates')->willReturn($updates);
84
        $this->unitOfWork->expects(self::any())->method('getScheduledEntityDeletions')->willReturn($deletions);
85
86
        $this->entityManager->expects(self::any())->method('getUnitOfWork')->willReturn($this->unitOfWork);
87
88
        $eventArgs = $this->createMock(OnFlushEventArgs::class);
0 ignored issues
show
Bug introduced by
It seems like createMock() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

88
        /** @scrutinizer ignore-call */ 
89
        $eventArgs = $this->createMock(OnFlushEventArgs::class);
Loading history...
89
        $eventArgs->expects(self::any())->method('getEntityManager')->willReturn($this->entityManager);
90
91
        return $eventArgs;
92
    }
93
}
94