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.

settingAggregateShouldCorrectlySetTheProperty()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dsantang\DomainEventsDoctrine\Tests\Unit;
6
7
use Dsantang\DomainEvents\DomainEvent;
8
use Dsantang\DomainEventsDoctrine\EventsTracker;
9
use PHPUnit\Framework\TestCase;
10
use ReflectionClass;
11
12
final class EventsTrackerTest extends TestCase
13
{
14
    private EventsTracker $tracker;
15
16
    /** @var DomainEvent[] */
17
    private array $events;
18
19
    /**
20
     * @before
21
     */
22
    public function setUpDependencies(): void
23
    {
24
        $event1 = $this->createMock(DomainEvent::class);
25
        $event2 = $this->createMock(DomainEvent::class);
26
27
        $this->events = [$event1, $event2];
0 ignored issues
show
Documentation Bug introduced by
It seems like array($event1, $event2) of type array<integer,PHPUnit\Fr...\MockObject\MockObject> is incompatible with the declared type Dsantang\DomainEvents\DomainEvent[] of property $events.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28
29
        $this->tracker = new EventsTracker();
30
    }
31
32
    /**
33
     * @test
34
     */
35
    public function settingAggregateShouldCorrectlySetTheProperty(): void
36
    {
37
        $this->tracker->aggregate(...$this->events);
38
39
        self::assertAttributeSame($this->events, 'events', $this->tracker);
40
    }
41
42
    /**
43
     * @test
44
     */
45
    public function releaseShouldReturnTheEventsAndResetTheInternalState(): void
46
    {
47
        $this->tracker->aggregate(...$this->events);
48
49
        self::assertSame($this->events, $this->tracker->release());
50
        self::assertAttributeSame([], 'events', $this->tracker);
51
    }
52
53
    /**
54
     * @param array<DomainEvent> $expectedDomainEvents
55
     */
56
    private static function assertAttributeSame(
57
        array $expectedDomainEvents,
58
        string $propertyName,
59
        EventsTracker $eventsTracker
60
    ): void {
61
        $refl = (new ReflectionClass($eventsTracker))->getProperty($propertyName);
62
        $refl->setAccessible(true);
63
64
        self::assertSame($expectedDomainEvents, $refl->getValue($eventsTracker));
65
    }
66
}
67