php-plug-altum/tests/AltumManagerTest.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

45 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
use Core\Plug\Altum\AltumManager;
use Core\Plug\Altum\Analytics\Client as AnalyticsClient;
use Core\Plug\Altum\Biolinks\Client as BiolinksClient;
use Core\Plug\Altum\Pusher\Client as PusherClient;
use Core\Plug\Altum\Socialproof\Client as SocialproofClient;
beforeEach(function () {
$this->manager = new AltumManager([
'analytics' => ['url' => 'https://analytics.test', 'admin_key' => 'akey'],
'biolinks' => ['url' => 'https://bio.test', 'admin_key' => 'bkey'],
'pusher' => ['url' => 'https://push.test', 'admin_key' => 'pkey'],
'socialproof' => ['url' => 'https://trust.test', 'admin_key' => 'skey'],
]);
});
it('creates analytics client', function () {
expect($this->manager->analytics())->toBeInstanceOf(AnalyticsClient::class);
});
it('creates biolinks client', function () {
expect($this->manager->biolinks())->toBeInstanceOf(BiolinksClient::class);
});
it('creates pusher client', function () {
expect($this->manager->pusher())->toBeInstanceOf(PusherClient::class);
});
it('creates socialproof client', function () {
expect($this->manager->socialproof())->toBeInstanceOf(SocialproofClient::class);
});
it('passes user API key to client', function () {
$client = $this->manager->analytics('my-user-key');
\Illuminate\Support\Facades\Http::fake(['*' => \Illuminate\Support\Facades\Http::response([], 200)]);
$client->user();
})->throwsNoExceptions();
it('throws on unconfigured product', function () {
$mgr = new AltumManager([]);
$mgr->analytics();
})->throws(\RuntimeException::class, 'not configured');