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:47
created

MapBasedEventsHandlerTest.php$0 ➔ getEventArgs()   A

Complexity

Conditions 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dsantang\DomainEventsDoctrine\Tests\Integration;
6
7
use Doctrine\ORM\EntityManagerInterface;
8
use Doctrine\ORM\Event\OnFlushEventArgs;
9
use Doctrine\ORM\UnitOfWork;
10
use Dsantang\DomainEvents\DomainEvent;
11
use Dsantang\DomainEvents\EventAware;
12
use Dsantang\DomainEvents\Registry\OrderedEventRegistry;
13
use Dsantang\DomainEventsDoctrine\Outbox\EventsHandler;
14
use Dsantang\DomainEventsDoctrine\Outbox\MapBased;
15
use Dsantang\DomainEventsDoctrine\Tests\OutboxSubClass;
16
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\Converters\FirstOutboxConverter;
17
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\FirstDomainEvent;
18
use PHPUnit\Framework\TestCase;
19
20
final class MapBasedEventsHandlerTest extends TestCase
21
{
22
    /** @var EventsHandler */
23
    private $mapBasedEventsHandler;
24
25
    /**
26
     * @before
27
     */
28
    public function setUpDependencies() : void
29
    {
30
        $this->mapBasedEventsHandler = new MapBased(
31
            new OutboxSubClass(),
32
            [
33
                'Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\FirstDomainEvent'  =>
34
                    new FirstOutboxConverter(),
35
            ]
36
        );
37
    }
38
39
    public function testOutboxHappyPathWorkflowOnFlushEvent() : void
40
    {
41
        $entity = new class() implements EventAware {
42
            use OrderedEventRegistry;
43
44
            public function trigger(DomainEvent $event) : void
45
            {
46
                $this->triggeredA($event);
47
            }
48
        };
49
50
        $domainEvent = new FirstDomainEvent();
51
        $entity->trigger($domainEvent);
52
53
        $eventArgs = $this->getEventArgs($entity);
54
55
        $this->mapBasedEventsHandler->onFlush($eventArgs);
56
    }
57
58
59
    private function getEventArgs(EventAware $entity) : OnFlushEventArgs
60
    {
61
        $unitOfWork = $this->createMock(UnitOfWork::class);
62
        $unitOfWork->expects(self::once())->method('getScheduledEntityInsertions')->willReturn([$entity]);
63
        $unitOfWork->expects(self::once())->method('getScheduledEntityUpdates')->willReturn([]);
64
        $unitOfWork->expects(self::once())->method('getScheduledEntityDeletions')->willReturn([]);
65
66
        $entityManager = $this->createMock(EntityManagerInterface::class);
67
        $entityManager->expects(self::any())->method('getUnitOfWork')->willReturn($unitOfWork);
68
69
        $eventArgs = $this->createMock(OnFlushEventArgs::class);
70
        $eventArgs->expects(self::any())->method('getEntityManager')->willReturn($entityManager);
71
72
        return $eventArgs;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $eventArgs returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return Doctrine\ORM\Event\OnFlushEventArgs.
Loading history...
73
    }
74
}
75