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
03:01 queued 55s
created

MapBasedEventsHandlerTest::getEntityClass()

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
nc 1
nop 0
dl 0
loc 8
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A MapBasedEventsHandlerTest.php$0 ➔ trigger() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dsantang\DomainEventsDoctrine\Tests\Integration;
6
7
use Doctrine\Common\EventArgs;
8
use Doctrine\ORM\EntityManagerInterface;
9
use Doctrine\ORM\Event\OnFlushEventArgs;
10
use Doctrine\ORM\UnitOfWork;
11
use Dsantang\DomainEvents\DomainEvent;
12
use Dsantang\DomainEvents\EventAware;
13
use Dsantang\DomainEvents\Registry\OrderedEventRegistry;
14
use Dsantang\DomainEventsDoctrine\Outbox\EventsHandler;
15
use Dsantang\DomainEventsDoctrine\Outbox\MapBased;
16
use Dsantang\DomainEventsDoctrine\Tests\OutboxSubClass;
17
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\Converters\FirstOutboxConverter;
18
use Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\FirstDomainEvent;
19
use PHPUnit\Framework\TestCase;
20
21
final class MapBasedEventsHandlerTest extends TestCase
22
{
23
    /** @var EventsHandler */
24
    private $mapBasedEventsHandler;
25
26
    /**
27
     * @before
28
     */
29
    public function setUpDependencies() : void
30
    {
31
        $this->mapBasedEventsHandler = new MapBased(
32
            new OutboxSubClass(),
33
            [
34
                'Dsantang\DomainEventsDoctrine\Tests\Unit\Outbox\Stub\DomainEvents\FirstDomainEvent'  =>
35
                    new FirstOutboxConverter(),
36
            ]
37
        );
38
    }
39
40
    public function testOutboxHappyPathWorkflowOnFlushEvent() : void
41
    {
42
        $entity      = $this->getEntityClass();
43
        $domainEvent = new FirstDomainEvent();
44
        $entity->trigger($domainEvent);
45
46
        $eventArgs = $this->getEventArgs($entity);
47
48
        $this->mapBasedEventsHandler->onFlush($eventArgs);
49
    }
50
51
52
    private function getEventArgs(EventAware $entity) : EventArgs
53
    {
54
        $unitOfWork = $this->createMock(UnitOfWork::class);
55
        $unitOfWork->expects(self::once())->method('getScheduledEntityInsertions')->willReturn([$entity]);
56
        $unitOfWork->expects(self::once())->method('getScheduledEntityUpdates')->willReturn([]);
57
        $unitOfWork->expects(self::once())->method('getScheduledEntityDeletions')->willReturn([]);
58
59
        $entityManager = $this->createMock(EntityManagerInterface::class);
60
        $entityManager->expects(self::any())->method('getUnitOfWork')->willReturn($unitOfWork);
61
62
        $eventArgs = $this->createMock(OnFlushEventArgs::class);
63
        $eventArgs->expects(self::any())->method('getEntityManager')->willReturn($entityManager);
64
65
        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\Common\EventArgs.
Loading history...
66
    }
67
68
    private function getEntityClass() : EventAware
69
    {
70
        return new class() implements EventAware {
71
            use OrderedEventRegistry;
72
73
            public function trigger(DomainEvent $event) : void
74
            {
75
                $this->triggeredA($event);
76
            }
77
        };
78
    }
79
}
80