1
0
mirror of synced 2024-11-25 06:46:07 +03:00
api-client-php/tests/src/ResourceGroup/NotificationsTest.php
2023-03-31 14:09:58 +03:00

41 lines
1.3 KiB
PHP

<?php
namespace RetailCrm\Tests\ResourceGroup;
use RetailCrm\Api\Enum\RequestMethod;
use RetailCrm\Api\Model\Entity\Notifications\Notification;
use RetailCrm\Api\Model\Request\Notifications\NotificationsSendRequest;
use RetailCrm\TestUtils\Factory\TestClientFactory;
use RetailCrm\TestUtils\TestCase\AbstractApiResourceGroupTestCase;
class NotificationsTest extends AbstractApiResourceGroupTestCase
{
public function testSend(): void
{
$json = <<<'EOF'
{
"success": true
}
EOF;
$notification = new Notification();
$notification->type = 'api.info';
$notification->message = '<p>some notification</p>';
$notification->userGroups = ['superadmins'];
$request = new NotificationsSendRequest();
$request->notification = $notification;
$mock = static::createApiMockBuilder('notifications/send');
$mock->matchMethod(RequestMethod::POST)
->matchBody(self::encodeForm($request))
->reply(200)
->withBody($json);
$client = TestClientFactory::createClient($mock->getClient());
$response = $client->notifications->send($request);
self::assertModelEqualsToResponse($json, $response);
}
}