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
Push — master ( 7859c5...12a294 )
by Giacomo
55s queued 12s
created

testGetDomainsEventsReturnsAllExpectedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 17
rs 10
cc 1
nc 1
nop 0
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
use function array_values;
21
22
final class StubMapBasedTest extends TestCase
23
{
24
    use EventArgsProvider;
25
26
    /**
27
     * @before
28
     */
29
    public function setUpDependencies() : void
30
    {
31
        $this->entityManager = $this->createMock(EntityManagerInterface::class);
32
        $this->unitOfWork    = $this->createMock(UnitOfWork::class);
33
    }
34
35
    public function testGetDomainsEventsReturnsAllExpectedEvents() : void
36
    {
37
        Counter::reset();
38
39
        $eventArgs = $this->getEventArgs();
40
41
        self::assertEquals(3, Counter::getNext());
42
43
        $mapBasedEventsHandler = new StubMapBased(new OutboxSubClass());
44
45
        $eventsResult = $mapBasedEventsHandler->getDomainEvents($eventArgs);
46
47
        self::assertEquals(0, Counter::getNext());
48
49
        $eventsExpected = [new FirstDomainEvent(), new SecondDomainEvent(), new ThirdDomainEvent(), new DeletionEvent()];
50
51
         self::assertEquals(array_values($eventsExpected), array_values($eventsResult));
52
    }
53
54
    /**
55
     * @return mixed[] array
56
     */
57
    public function persistDataProvider() : array
58
    {
59
        return [
60
            [[], 0, 0],
61
            [[new FirstOutboxEntry(new FirstDomainEvent())], 1, 1],
62
            [
63
                [
64
                    new ThirdOutboxEntry(new ThirdDomainEvent()),
65
                    new FirstOutboxEntry(new FirstDomainEvent()),
66
                    new SecondOutboxEntry(new SecondDomainEvent()),
67
                ], 3,
68
                1,
69
            ],
70
        ];
71
    }
72
73
    /**
74
     * @param mixed[] $outboxEvents
75
     *
76
     * @dataProvider persistDataProvider
77
     */
78
    public function testPersist(array $outboxEvents, int $persistCalls, int $computeChangeSetsCalls) : void
79
    {
80
        $eventArgs = $this->getEventArgs();
81
82
        $mapBasedEventsHandler = new StubMapBased(new OutboxSubClass());
83
84
        $this->entityManager->expects(self::exactly($persistCalls))->method('persist');
85
86
        $this->unitOfWork->expects(self::exactly($computeChangeSetsCalls))->method('computeChangeSets');
87
88
        $mapBasedEventsHandler->persist($eventArgs->getEntityManager(), ...$outboxEvents);
89
    }
90
}
91