forked from nextcloud/deck
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebhookCompatibleEventsTest.php
More file actions
57 lines (45 loc) · 1.68 KB
/
Copy pathWebhookCompatibleEventsTest.php
File metadata and controls
57 lines (45 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
namespace OCA\Deck\Event;
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\Card;
use OCP\EventDispatcher\IWebhookCompatibleEvent;
use Test\TestCase;
class WebhookCompatibleEventsTest extends TestCase {
public function testCardEventIsWebhookCompatible(): void {
$card = new Card();
$card->setId(42);
$card->setTitle('Test card');
$card->setStackId(1);
$event = new CardCreatedEvent($card);
$this->assertInstanceOf(IWebhookCompatibleEvent::class, $event);
$payload = $event->getWebhookSerializable();
$this->assertArrayHasKey('card', $payload);
$this->assertSame(42, $payload['card']['id']);
$this->assertSame('Test card', $payload['card']['title']);
}
public function testAclEventIsWebhookCompatible(): void {
$acl = new Acl();
$acl->setId(7);
$acl->setBoardId(3);
$acl->setType(Acl::PERMISSION_TYPE_USER);
$acl->setParticipant('alice');
$acl->setPermissionEdit(true);
$event = new AclCreatedEvent($acl);
$this->assertInstanceOf(IWebhookCompatibleEvent::class, $event);
$payload = $event->getWebhookSerializable();
$this->assertArrayHasKey('acl', $payload);
$this->assertSame(7, $payload['acl']['id']);
$this->assertSame(3, $payload['acl']['boardId']);
$this->assertArrayNotHasKey('token', $payload['acl'], 'token must be stripped from serialized ACL');
}
public function testBoardUpdatedEventIsWebhookCompatible(): void {
$event = new BoardUpdatedEvent(99);
$this->assertInstanceOf(IWebhookCompatibleEvent::class, $event);
$this->assertSame(['boardId' => 99], $event->getWebhookSerializable());
}
}