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

40 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
use Core\Plug\Altum\Biolinks\Client;
use Illuminate\Support\Facades\Http;
beforeEach(function () {
$this->client = new Client(
baseUrl: 'https://bio.test',
adminApiKey: 'admin-key',
userApiKey: 'user-key',
);
Http::fake(['*' => Http::response(['data' => []], 200)]);
});
it('lists links', function () {
$this->client->links();
Http::assertSent(fn ($r) => str_contains($r->url(), '/api/links/'));
});
it('creates a link', function () {
$this->client->createLink(['url' => 'https://example.com', 'type' => 'link']);
Http::assertSent(fn ($r) => $r->method() === 'POST' && str_contains($r->url(), '/api/links'));
});
it('gets link statistics', function () {
$this->client->linkStatistics(42);
Http::assertSent(fn ($r) => str_contains($r->url(), '/api/statistics/42'));
});
it('lists projects', function () {
$this->client->projects();
Http::assertSent(fn ($r) => str_contains($r->url(), '/api/projects/'));
});
it('creates QR codes', function () {
$this->client->createQrCode(['name' => 'Test QR', 'link_id' => 1]);
Http::assertSent(fn ($r) => $r->method() === 'POST' && str_contains($r->url(), '/api/qr-codes'));
});