46 lines
1.6 KiB
PHP
46 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');
|