mirror of
https://github.com/jonathan-martz/pocketbase-php-sdk.git
synced 2026-04-03 07:27:42 +00:00
refactoring collection a little bit, adjust token from collection manual,write some test for the simple logic, fixing superusers authAdmin
This commit is contained in:
48
tests/ClientTest.php
Normal file
48
tests/ClientTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use Pb\Client;
|
||||
use Pb\Collection;
|
||||
use Pb\Settings;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class ClientTest extends TestCase
|
||||
{
|
||||
private Collection $collection;
|
||||
private ?string $url;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->url = getenv('POCKETBASE_URL') ?: 'https://admin.pocketbase.dev';
|
||||
$this->collection = new Collection($this->url, 'users');
|
||||
}
|
||||
|
||||
public function test_collection(): void
|
||||
{
|
||||
$pb = new Client($this->url);
|
||||
|
||||
$actual = $pb->collection('users');
|
||||
|
||||
$this->assertEquals($actual, $this->collection);
|
||||
}
|
||||
|
||||
public function test_settings(): void
|
||||
{
|
||||
$pb = new Client($this->url);
|
||||
|
||||
$actual = $pb->settings();
|
||||
|
||||
$this->assertEquals($actual, new Settings($this->url));
|
||||
}
|
||||
|
||||
public function test_setToken(){
|
||||
$token = 'test123';
|
||||
|
||||
$pb = new Client($this->url);
|
||||
$pb->setAuthToken($token);
|
||||
|
||||
$this->assertEquals($token, $pb->getAuthToken());
|
||||
$this->assertEquals($token, $pb->token);
|
||||
$pb->token = 'test456';
|
||||
$this->assertEquals('test456', $pb->getAuthToken());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user