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.

StubMapBasedTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
eloc 21
c 3
b 0
f 0
dl 0
loc 68
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUpDependencies() 0 4 1
A testPersist() 0 11 1
A persistDataProvider() 0 13 1
A testGetDomainsEventsReturnsAllExpectedEvents() 0 17 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox;
6
7
use Doctrine\ORM\EntityManagerInterface;
8
use Doctrine\ORM\UnitOfWork;
9
use Dsantang\DomainEvents\Counter;
10
use Dsantang\DomainEventsDoctrine\Tests\OutboxSubClass;
11
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\DeletionEvent;
12
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\FirstDomainEvent;
13
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\SecondDomainEvent;
14
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\ThirdDomainEvent;
15
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\OutboxEntries\FirstOutboxEntry;
16
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\OutboxEntries\SecondOutboxEntry;
17
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\OutboxEntries\ThirdOutboxEntry;
18
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\StubMapBased;
19
use PHPUnit\Framework\TestCase;
20
21
use function array_values;
22
23
final class StubMapBasedTest extends TestCase
24
{
25
    use EventArgsProvider;
26
27
    /**
28
     * @before
29
     */
30
    public function setUpDependencies(): void
31
    {
32
        $this->entityManager = $this->createMock(EntityManagerInterface::class);
33
        $this->unitOfWork    = $this->createMock(UnitOfWork::class);
34
    }
35
36
    public function testGetDomainsEventsReturnsAllExpectedEvents(): void
37
    {
38
        Counter::reset();
39
40
        $eventArgs = $this->getEventArgs();
41
42
        self::assertEquals(3, Counter::getNext());
43
44
        $mapBasedEventsHandler = new StubMapBased(new OutboxSubClass());
45
46
        $eventsResult = $mapBasedEventsHandler->getDomainEvents($eventArgs);
47
48
        self::assertEquals(0, Counter::getNext());
49
50
        $eventsExpected = [new FirstDomainEvent(), new SecondDomainEvent(), new ThirdDomainEvent(), new DeletionEvent()];
51
52
         self::assertEquals(array_values($eventsExpected), array_values($eventsResult));
53
    }
54
55
    /**
56
     * @return mixed[] array
57
     */
58
    public function persistDataProvider(): array
59
    {
60
        return [
61
            [[], 0, 0],
62
            [[new FirstOutboxEntry(new FirstDomainEvent())], 1, 1],
63
            [
64
                [
65
                    new ThirdOutboxEntry(new ThirdDomainEvent()),
66
                    new FirstOutboxEntry(new FirstDomainEvent()),
67
                    new SecondOutboxEntry(new SecondDomainEvent()),
68
                ],
69
                3,
70
                1,
71
            ],
72
        ];
73
    }
74
75
    /**
76
     * @param mixed[] $outboxEvents
77
     *
78
     * @dataProvider persistDataProvider
79
     */
80
    public function testPersist(array $outboxEvents, int $persistCalls, int $computeChangeSetsCalls): void
81
    {
82
        $eventArgs = $this->getEventArgs();
83
84
        $mapBasedEventsHandler = new StubMapBased(new OutboxSubClass());
85
86
        $this->entityManager->expects(self::exactly($persistCalls))->method('persist');
87
88
        $this->unitOfWork->expects(self::exactly($computeChangeSetsCalls))->method('computeChangeSets');
89
90
        $mapBasedEventsHandler->persist($eventArgs->getEntityManager(), ...$outboxEvents);
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\ORM\Event\OnFlu...rgs::getEntityManager() has been deprecated: 2.13. Use {@see getObjectManager} instead. ( Ignorable by Annotation )

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

90
        $mapBasedEventsHandler->persist(/** @scrutinizer ignore-deprecated */ $eventArgs->getEntityManager(), ...$outboxEvents);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
91
    }
92
}
93