webhookMock = $this->createMock(Webhook::class); $this->webhookFileRegistryMock = $this->createMock(WebhookFileRegistry::class); $this->serviceManager = $this->createMock(ServiceManager::class); $this->serviceManager ->method('get') ->with(WebhookFileRegistry::class) ->willReturn($this->webhookFileRegistryMock); $this->subject = new WebhookRegistryManager(); $this->subject->setServiceLocator( $this->serviceManager ); } public function testAddWebhookConfig(): void { $this->webhookFileRegistryMock ->expects($this->exactly(2)) ->method('getOption') ->withConsecutive( [ 'webhooks', ], [ 'events', ] ) ->willReturnOnConsecutiveCalls( [], [] ); $this->webhookMock ->expects($this->exactly(2)) ->method('getid') ->willReturn('webhookId'); $this->webhookMock ->expects($this->once()) ->method('toArray') ->willReturn( [ 'id' => 'webhookId', ] ); $this->webhookFileRegistryMock ->expects($this->exactly(2)) ->method('setOption') ->withConsecutive( ['webhooks', [ 'webhookId' => [ 'id' => 'webhookId', ] ]], ['events', [ 'SomeEventClass' => [ 'webhookId' ] ]] ); $this->serviceManager ->expects($this->once()) ->method('register') ->with( WebhookFileRegistry::SERVICE_ID, $this->webhookFileRegistryMock ); $this->subject->addWebhookConfig($this->webhookMock, 'SomeEventClass'); } }