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.
Passed
Pull Request — master (#7)
by Fábio Tadeu da
02:35 queued 12s
created

ovider.php$1   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 6
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
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\DomainEvent;
9
use Dsantang\DomainEvents\EventAware;
10
use Dsantang\DomainEvents\Registry\OrderedEventRegistry;
11
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\FirstDomainEvent;
12
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\SecondDomainEvent;
13
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\ThirdDomainEvent;
14
use PHPUnit\Framework\MockObject\MockObject;
15
16
trait EventArgsProvider
17
{
18
    /** @var MockObject entityManager */
19
    private $entityManager;
20
21
    /** @var MockObject unitOfWork */
22
    private $unitOfWork;
23
24
    /**
25
     * @return OnFlushEventArgs|MockObject
26
     */
27
    private function getEventArgs(bool $withEvents = true) : OnFlushEventArgs
28
    {
29
        $insertions = $updates = $deletions = [];
30
31
        if ($withEvents) {
32
            $entity1 = new class() implements EventAware {
33
                use OrderedEventRegistry;
34
35
                public function trigger(DomainEvent $event) : void
36
                {
37
                    $this->triggeredA($event);
38
                }
39
            };
40
41
            $entity2 = new class() implements EventAware {
42
                use OrderedEventRegistry;
43
44
                public function trigger(DomainEvent $event) : void
45
                {
46
                    $this->triggeredA($event);
47
                }
48
            };
49
50
            $entity3 = new class() implements EventAware {
51
                use OrderedEventRegistry;
52
53
                public function trigger(DomainEvent $event) : void
54
                {
55
                    $this->triggeredA($event);
56
                }
57
            };
58
59
            $domainEvent1 = new FirstDomainEvent();
60
            $domainEvent2 = new SecondDomainEvent();
61
            $domainEvent3 = new ThirdDomainEvent();
62
63
            $entity1->trigger($domainEvent1);
64
            $entity2->trigger($domainEvent2);
65
            $entity3->trigger($domainEvent3);
66
67
            $updates   = [$entity3];
68
            $deletions = [$entity2, $entity1];
69
        }
70
71
        $this->unitOfWork->expects(self::any())->method('getScheduledEntityInsertions')->willReturn($insertions);
72
        $this->unitOfWork->expects(self::any())->method('getScheduledEntityUpdates')->willReturn($updates);
73
        $this->unitOfWork->expects(self::any())->method('getScheduledEntityDeletions')->willReturn($deletions);
74
75
        $this->entityManager->expects(self::any())->method('getUnitOfWork')->willReturn($this->unitOfWork);
76
77
        $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

77
        /** @scrutinizer ignore-call */ 
78
        $eventArgs = $this->createMock(OnFlushEventArgs::class);
Loading history...
78
        $eventArgs->expects(self::any())->method('getEntityManager')->willReturn($this->entityManager);
79
80
        return $eventArgs;
81
    }
82
}
83