Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/Unit/PushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

/**
Expand Down Expand Up @@ -453,6 +454,22 @@ public function testPushToDeviceSending(bool $isDebug, string $padding): void {
->method('getUser')
->willReturn('valid');

$notification
->method('getParsedSubject')
->willReturn('ParsedSubject');

$notification
->method('getApp')
->willReturn('PushTestApp');

$notification
->method('getObjectType')
->willReturn('PushTestType');

$notification
->method('getObjectId')
->willReturn('PushTestObjectId');

/** @var IUser&MockObject $user */
$user = $this->createMock(IUser::class);

Expand Down Expand Up @@ -714,7 +731,27 @@ public function testPushToDeviceSending(bool $isDebug, string $padding): void {
$push->method('deletePushTokenByDeviceIdentifier')
->with('badrequest-with-devices', '123456');

/** @var OutputInterface&MockObject $user */
$output = $this->createMock(OutputInterface::class);
$foundExpectedJsonData = false;
$output
->method('writeln')
->willReturnCallback(function ($string) use (&$foundExpectedJsonData) {
if (str_contains($string, '"subject":"ParsedSubject"')
&& str_contains($string, '"nid":207787')
&& str_contains($string, '"type":"PushTestType"')
&& str_contains($string, '"id":"PushTestObjectId"')
&& str_contains($string, '"app":"PushTestApp"')) {

$foundExpectedJsonData = true;
}
});

$push->setOutput($output);

$push->pushToDevice(207787, $notification);

$this->assertTrue($foundExpectedJsonData, 'Failed to find correct subject, nid, type, id or app in json encoded push data');
}

public static function dataPushToDeviceTalkNotification(): array {
Expand Down
Loading