36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use Core\Plug\Altum\Socialproof\Client;
|
||
|
|
use Illuminate\Support\Facades\Http;
|
||
|
|
|
||
|
|
beforeEach(function () {
|
||
|
|
$this->client = new Client(
|
||
|
|
baseUrl: 'https://trust.test',
|
||
|
|
adminApiKey: 'admin-key',
|
||
|
|
userApiKey: 'user-key',
|
||
|
|
);
|
||
|
|
Http::fake(['*' => Http::response(['data' => []], 200)]);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('lists campaigns', function () {
|
||
|
|
$this->client->campaigns();
|
||
|
|
Http::assertSent(fn ($r) => str_contains($r->url(), '/api/campaigns/'));
|
||
|
|
});
|
||
|
|
|
||
|
|
it('creates a campaign', function () {
|
||
|
|
$this->client->createCampaign(['name' => 'Test Campaign', 'type' => 'recent_activity']);
|
||
|
|
Http::assertSent(fn ($r) => $r->method() === 'POST' && str_contains($r->url(), '/api/campaigns'));
|
||
|
|
});
|
||
|
|
|
||
|
|
it('manages notifications within campaigns', function () {
|
||
|
|
$this->client->createNotification(['campaign_id' => 1, 'title' => 'New sale']);
|
||
|
|
Http::assertSent(fn ($r) => $r->method() === 'POST' && str_contains($r->url(), '/api/notifications'));
|
||
|
|
});
|
||
|
|
|
||
|
|
it('fetches statistics', function () {
|
||
|
|
$this->client->statistics();
|
||
|
|
Http::assertSent(fn ($r) => str_contains($r->url(), '/api/statistics/'));
|
||
|
|
});
|