|
|
|
@ -124,4 +124,49 @@ class WebhookListenerMapperTest extends TestCase { |
|
|
|
|
$listener1->resetUpdatedFields(); |
|
|
|
|
$this->assertEquals($listener1, $listener2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testInsertListenerAndGetItByEventAndUser() { |
|
|
|
|
$listener1 = $this->mapper->addWebhookListener( |
|
|
|
|
null, |
|
|
|
|
'bob', |
|
|
|
|
'POST', |
|
|
|
|
'https://webhook.example.com/endpoint', |
|
|
|
|
NodeWrittenEvent::class, |
|
|
|
|
null, |
|
|
|
|
'alice', |
|
|
|
|
null, |
|
|
|
|
AuthMethod::None, |
|
|
|
|
null, |
|
|
|
|
); |
|
|
|
|
$listener1->resetUpdatedFields(); |
|
|
|
|
|
|
|
|
|
$this->assertEquals([NodeWrittenEvent::class], $this->mapper->getAllConfiguredEvents('alice')); |
|
|
|
|
$this->assertEquals([], $this->mapper->getAllConfiguredEvents('')); |
|
|
|
|
$this->assertEquals([], $this->mapper->getAllConfiguredEvents('otherUser')); |
|
|
|
|
|
|
|
|
|
$this->assertEquals([$listener1], $this->mapper->getByEvent(NodeWrittenEvent::class, 'alice')); |
|
|
|
|
$this->assertEquals([], $this->mapper->getByEvent(NodeWrittenEvent::class, '')); |
|
|
|
|
$this->assertEquals([], $this->mapper->getByEvent(NodeWrittenEvent::class, 'otherUser')); |
|
|
|
|
|
|
|
|
|
/* Add a second listener with no user filter */ |
|
|
|
|
$listener2 = $this->mapper->addWebhookListener( |
|
|
|
|
null, |
|
|
|
|
'bob', |
|
|
|
|
'POST', |
|
|
|
|
'https://webhook.example.com/endpoint', |
|
|
|
|
NodeWrittenEvent::class, |
|
|
|
|
null, |
|
|
|
|
'', |
|
|
|
|
null, |
|
|
|
|
AuthMethod::None, |
|
|
|
|
null, |
|
|
|
|
); |
|
|
|
|
$listener2->resetUpdatedFields(); |
|
|
|
|
|
|
|
|
|
$this->assertEquals([NodeWrittenEvent::class], $this->mapper->getAllConfiguredEvents('alice')); |
|
|
|
|
$this->assertEquals([NodeWrittenEvent::class], $this->mapper->getAllConfiguredEvents('')); |
|
|
|
|
|
|
|
|
|
$this->assertEquals([$listener1, $listener2], $this->mapper->getByEvent(NodeWrittenEvent::class, 'alice')); |
|
|
|
|
$this->assertEquals([$listener2], $this->mapper->getByEvent(NodeWrittenEvent::class, 'otherUser')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|