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.
Test Failed
Push — master ( 99496c...f0f55b )
by Giacomo
12:21 queued 12s
created

DoctrineEventsRecorderTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 31
c 2
b 0
f 0
dl 0
loc 63
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ provideEventAwareChangedEntities() 0 14 1
provideEventAwareChangedEntities() 0 14 ?
A hp$0 ➔ __construct() 0 3 1
A onFlushWillAggregateAllTheEventAwareEntities() 0 35 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dsantang\DomainEventsDoctrine\Tests\Unit\EventsRecorder;
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\EventsRegistry;
13
use Dsantang\DomainEventsDoctrine\Aggregator;
14
use Dsantang\DomainEventsDoctrine\EventsRecorder\DoctrineEventsRecorder;
15
use Dsantang\DomainEventsDoctrine\Tests\RandomDomainEvent;
16
use phpDocumentor\Reflection\Types\Object_;
17
use PHPUnit\Framework\TestCase;
18
19
final class DoctrineEventsRecorderTest extends TestCase
20
{
21
    /**
22
     * @param DomainEvent[] $domainEvents
23
     *
24
     * @dataProvider provideEventAwareChangedEntities
25
     *
26
     * @test
27
     */
28
    public function onFlushWillAggregateAllTheEventAwareEntities(object $eventAwareEntity, array $domainEvents): void
29
    {
30
        $unitOfWork = $this->createMock(UnitOfWork::class);
31
32
        $unitOfWork->expects(self::once())
33
                   ->method('getScheduledEntityDeletions')
34
                   ->willReturn([new Object_()]);
35
36
        $unitOfWork->expects(self::once())
37
                   ->method('getScheduledEntityInsertions')
38
                   ->willReturn([new Object_()]);
39
40
        $unitOfWork->expects(self::once())
41
                   ->method('getScheduledEntityUpdates')
42
                   ->willReturn([$eventAwareEntity]);
43
44
        $entityManager = $this->createMock(EntityManagerInterface::class);
45
        $entityManager->expects(self::once())
46
                      ->method('getUnitOfWork')
47
                      ->willReturn($unitOfWork);
48
49
        $aggregator = $this->createMock(Aggregator::class);
50
51
        $aggregator->expects(self::once())
52
                   ->method('aggregate')
53
                   ->with(...$domainEvents);
54
55
        $eventRecorder = new DoctrineEventsRecorder($aggregator);
56
57
        $eventArgs = $this->createMock(OnFlushEventArgs::class);
58
        $eventArgs->expects(self::once())
59
                  ->method('getEntityManager')
60
                  ->willReturn($entityManager);
61
62
        $eventRecorder->onFlush($eventArgs);
63
    }
64
65
    /**
66
     * @return mixed[] array
67
     */
68
    public function provideEventAwareChangedEntities(): array
69
    {
70
        $awareEntity = new class (new RandomDomainEvent()) implements EventAware {
71
            use EventsRegistry;
72
73
            public function __construct(DomainEvent $domainEvent)
74
            {
75
                $this->recordedEvents = [$domainEvent];
76
            }
77
        };
78
79
        return [
80
            'with no changed entities' => [new Object_(), []],
81
            'with a changed entity' => [$awareEntity, [new RandomDomainEvent()]],
82
        ];
83
    }
84
}
85