Skip to content

Commit

Permalink
Notification Tests (#90)
Browse files Browse the repository at this point in the history
* Notification Tests
  • Loading branch information
utxo-one authored Nov 9, 2022
1 parent 52e96a0 commit 840aa41
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions tests/NotificationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

namespace BTCPayServer\Tests;

use BTCPayServer\Client\Notification;
use BTCPayServer\Result\NotificationList;

final class NotificationTest extends BaseTest
{
public function setUp(): void
{
parent::setUp();

$this->notificationClient = new Notification($this->host, $this->apiKey);
}

/** @group getNotifications */
public function testItCanGetNotifications(): void
{
$notifications = $this->notificationClient->getNotifications();

$this->assertInstanceOf(NotificationList::class, $notifications);
foreach ($notifications->all() as $notification) {
$this->assertIsString($notification->getId());
$this->assertIsString($notification->getBody());
$this->assertIsString($notification->getLink());
$this->assertIsInt($notification->getCreatedTime());
$this->assertIsBool($notification->isSeen());
}
}

/** @group getNotification */
public function testItCanGetNotification(): void
{
$notifications = $this->notificationClient->getNotifications();
$notification = $this->notificationClient->getNotification($notifications->all()[0]->getId());

$this->assertIsString($notification->getId());
$this->assertIsString($notification->getBody());
$this->assertIsString($notification->getLink());
$this->assertIsInt($notification->getCreatedTime());
$this->assertIsBool($notification->isSeen());
}

/** @group updateNotification */
public function testItCanUpdateNotification(): void
{
$notifications = $this->notificationClient->getNotifications();
$notification = $this->notificationClient->updateNotification($notifications->all()[0]->getId(), true);

$this->assertIsString($notification->getId());
$this->assertIsString($notification->getBody());
$this->assertIsString($notification->getLink());
$this->assertIsInt($notification->getCreatedTime());
$this->assertTrue($notification->isSeen());
}

/** @group removeNotification */
public function testItCanRemoveNotification(): void
{
$notifications = $this->notificationClient->getNotifications();
$notification = $this->notificationClient->removeNotification($notifications->all()[0]->getId());

$this->assertTrue($notification);
}
}

0 comments on commit 840aa41

Please sign in to comment.