Code Duplication    Length = 12-17 lines in 2 locations

src/EventDispatcherTest.php 2 locations

@@ 60-71 (lines=12) @@
57
    /**
58
     * @test
59
     */
60
    public function it_uses_a_provided_listener_provider(): void
61
    {
62
        $listenerSpy = new ListenerSpy();
63
        $provider = new PrioritizedListenerCollection();
64
        $provider->subscribeTo(stdClass::class, $listenerSpy);
65
        $dispatcher = new EventDispatcher($provider);
66
        $event = new stdClass();
67
68
        $dispatcher->dispatch($event);
69
70
        $this->assertTrue($listenerSpy->wasCalledWith($event));
71
    }
72
73
    /**
74
     * @test
@@ 76-92 (lines=17) @@
73
    /**
74
     * @test
75
     */
76
    public function it_only_keeps_notifying_handlers_when_the_event_propagation_is_not_stopped(): void
77
    {
78
        $dispatcher = new EventDispatcher();
79
        $listenerSpy = new ListenerSpy();
80
        $event = new StubStoppableEvent();
81
82
        $dispatcher->subscribeTo(
83
            StubStoppableEvent::class,
84
            function (StubStoppableEvent $event) {
85
                $event->stopPropagation();
86
            }
87
        );
88
        $dispatcher->subscribeTo(StubStoppableEvent::class, $listenerSpy);
89
        $dispatcher->dispatch($event);
90
91
        $this->assertFalse($listenerSpy->wasCalledWith($event));
92
    }
93
94
    /**
95
     * @test