40 lines
1.2 KiB
PHP
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'));
|
|
});
|