php-plug-altum/tests/Socialproof/ClientTest.php
Snider 25a2903db3 test: add Pest tests for AltumClient, product clients, and AltumManager
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 08:53:09 +00:00

35 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/'));
});