36 lines
1 KiB
PHP
36 lines
1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use Core\Plug\Altum\Pusher\Client;
|
||
|
|
use Illuminate\Support\Facades\Http;
|
||
|
|
|
||
|
|
beforeEach(function () {
|
||
|
|
$this->client = new Client(
|
||
|
|
baseUrl: 'https://push.test',
|
||
|
|
adminApiKey: 'admin-key',
|
||
|
|
userApiKey: 'user-key',
|
||
|
|
);
|
||
|
|
Http::fake(['*' => Http::response(['data' => []], 200)]);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('lists subscribers', function () {
|
||
|
|
$this->client->subscribers();
|
||
|
|
Http::assertSent(fn ($r) => str_contains($r->url(), '/api/subscribers/'));
|
||
|
|
});
|
||
|
|
|
||
|
|
it('creates a campaign', function () {
|
||
|
|
$this->client->createCampaign(['title' => 'Test', 'url' => 'https://example.com']);
|
||
|
|
Http::assertSent(fn ($r) => $r->method() === 'POST' && str_contains($r->url(), '/api/campaigns'));
|
||
|
|
});
|
||
|
|
|
||
|
|
it('lists flows', function () {
|
||
|
|
$this->client->flows();
|
||
|
|
Http::assertSent(fn ($r) => str_contains($r->url(), '/api/flows/'));
|
||
|
|
});
|
||
|
|
|
||
|
|
it('creates segments', function () {
|
||
|
|
$this->client->createSegment(['name' => 'VIP']);
|
||
|
|
Http::assertSent(fn ($r) => $r->method() === 'POST' && str_contains($r->url(), '/api/segments'));
|
||
|
|
});
|