mirror of
https://github.com/jonathan-martz/pocketbase-php-sdk.git
synced 2026-04-03 07:27:42 +00:00
refactoring code, add doRequest via httpClient
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use Pb\Collection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -18,33 +19,17 @@ final class CollectionGetOneTest extends TestCase
|
||||
{
|
||||
$id = '6588yk36406qqv1';
|
||||
$actual = $this->collection->getOne($id);
|
||||
$expected = [
|
||||
'avatar' => '',
|
||||
'collectionId' => '_pb_users_auth_',
|
||||
'collectionName' => 'users',
|
||||
'created' => '2025-01-21 21:22:47.002Z',
|
||||
'emailVisibility' => false,
|
||||
'id' => '6588yk36406qqv1',
|
||||
'name' => 'Jonathan Martz',
|
||||
'updated' => '2025-01-21 21:22:47.002Z',
|
||||
'verified' => true
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->assertEquals($id, $actual['id']);
|
||||
$this->assertCount(9, $actual);
|
||||
}
|
||||
|
||||
public function test_getOneWrongId(): void
|
||||
{
|
||||
$id = '6588yk36406qqva';
|
||||
$actual = $this->collection->getOne($id);
|
||||
$expected = [
|
||||
'data' => [],
|
||||
'message' => "The requested resource wasn't found.",
|
||||
'status' => 404,
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->assertCount(3,$actual);
|
||||
$this->expectException(ClientException::class);
|
||||
|
||||
$this->collection->getOne($id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user