Code Duplication    Length = 12-17 lines in 2 locations

src/EventDispatcherTest.php 2 locations

@@ 73-84 (lines=12) @@
70
    /**
71
     * @test
72
     */
73
    public function it_uses_a_provided_listener_provider(): void
74
    {
75
        $listenerSpy = new ListenerSpy();
76
        $provider = new PrioritizedListenerRegistry();
77
        $provider->subscribeTo(stdClass::class, $listenerSpy);
78
        $dispatcher = new EventDispatcher($provider);
79
        $event = new stdClass();
80
81
        $dispatcher->dispatch($event);
82
83
        $this->assertTrue($listenerSpy->wasCalledWith($event));
84
    }
85
86
    /**
87
     * @test
@@ 89-105 (lines=17) @@
86
    /**
87
     * @test
88
     */
89
    public function it_only_keeps_notifying_handlers_when_the_event_propagation_is_not_stopped(): void
90
    {
91
        $dispatcher = new EventDispatcher();
92
        $listenerSpy = new ListenerSpy();
93
        $event = new StubStoppableEvent();
94
95
        $dispatcher->subscribeTo(
96
            StubStoppableEvent::class,
97
            function (StubStoppableEvent $event) {
98
                $event->stopPropagation();
99
            }
100
        );
101
        $dispatcher->subscribeTo(StubStoppableEvent::class, $listenerSpy);
102
        $dispatcher->dispatch($event);
103
104
        $this->assertFalse($listenerSpy->wasCalledWith($event));
105
    }
106
107
    /**
108
     * @test