innerDispatcher = $this->prophesize(EventDispatcherInterface::class); } /** * @test * @dataProvider provideIsSwoole */ public function callsInnerDispatcherOnlyWhenInSwooleContext(bool $isSwoole, int $expectedCalls): void { $dispatcher = new SwooleEventDispatcher($this->innerDispatcher->reveal(), $isSwoole); $event = new stdClass(); $dispatcher->dispatch($event); $this->innerDispatcher->dispatch($event)->shouldHaveBeenCalledTimes($expectedCalls); } public function provideIsSwoole(): iterable { yield 'with swoole' => [true, 1]; yield 'without swoole' => [false, 0]; } }