From abc61a9f63ba088aaea5b3c64d2db3316887061e Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 8 Feb 2021 11:34:19 +0100 Subject: Fix the legacy dispatcher argument order Signed-off-by: Christoph Wurst --- tests/lib/EventDispatcher/SymfonyAdapterTest.php | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests') diff --git a/tests/lib/EventDispatcher/SymfonyAdapterTest.php b/tests/lib/EventDispatcher/SymfonyAdapterTest.php index b1d43bf2661..5e2803624af 100644 --- a/tests/lib/EventDispatcher/SymfonyAdapterTest.php +++ b/tests/lib/EventDispatcher/SymfonyAdapterTest.php @@ -100,6 +100,26 @@ class SymfonyAdapterTest extends TestCase { self::assertEquals($result, $wrapped); } + public function testDispatchOldSymfonyEventWithFlippedArgumentOrder(): void { + $event = new SymfonyEvent(); + $eventName = 'symfony'; + $symfonyDispatcher = $this->createMock(SymfonyDispatcher::class); + $this->eventDispatcher->expects(self::once()) + ->method('getSymfonyDispatcher') + ->willReturn($symfonyDispatcher); + $symfonyDispatcher->expects(self::once()) + ->method('dispatch') + ->with( + $event, + $eventName + ) + ->willReturnArgument(0); + + $result = $this->adapter->dispatch($event, $eventName); + + self::assertSame($result, $event); + } + public function testDispatchOldSymfonyEvent(): void { $event = new SymfonyEvent(); $eventName = 'symfony'; @@ -120,6 +140,22 @@ class SymfonyAdapterTest extends TestCase { self::assertSame($result, $event); } + public function testDispatchCustomGenericEventWithFlippedArgumentOrder(): void { + $event = new GenericEvent(); + $eventName = 'symfony'; + $this->eventDispatcher->expects(self::once()) + ->method('dispatch') + ->with( + $eventName, + $event + ) + ->willReturnArgument(0); + + $result = $this->adapter->dispatch($event, $eventName); + + self::assertSame($result, $event); + } + public function testDispatchCustomGenericEvent(): void { $event = new GenericEvent(); $eventName = 'symfony'; -- cgit v1.2.3