Skip to content

Commit ac03da0

Browse files
committed
test: collection & collections
1 parent af960c6 commit ac03da0

1 file changed

Lines changed: 35 additions & 12 deletions

File tree

tests/Feature/CollectionTest.php

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,57 @@
77

88
class CollectionTest extends TestCase
99
{
10-
public function testCanCreateCollection(): void
10+
private $createCollectionRes = null;
11+
12+
13+
protected function setUp(): void
1114
{
15+
parent::setUp();
16+
1217
$schema = $this->getSchema('books');
18+
$this->createCollectionRes = $this->client()->collections->create($schema);
19+
}
1320

14-
$response = $this->client()->collections->create($schema);
21+
public function testCanCreateACollection(): void
22+
{
23+
$this->assertEquals('books', $this->createCollectionRes['name']);
24+
}
1525

26+
public function testCanRetrieveACollection(): void
27+
{
28+
$response = $this->client()->collections['books']->retrieve();
1629
$this->assertEquals('books', $response['name']);
1730
}
1831

19-
public function testCanRetrieveCollection(): void
32+
public function testCanUpdateACollection(): void
2033
{
21-
$schema = $this->getSchema('books');
22-
$this->client()->collections->create($schema);
34+
$update_schema = [
35+
'fields' => [
36+
[
37+
'name' => 'isbn',
38+
'drop' => true
39+
]
40+
]
41+
];
42+
$response = $this->client()->collections['books']->update($update_schema);
43+
$this->assertEquals('isbn', $response['fields'][0]['name']);
44+
$this->assertArrayHasKey('drop', $response['fields'][0]);
2345

2446
$response = $this->client()->collections['books']->retrieve();
25-
26-
$this->assertEquals('books', $response['name']);
47+
$this->assertEquals(5, count($response['fields']));
2748
}
2849

29-
public function testCanDeleteCollection(): void
50+
public function testCanDeleteACollection(): void
3051
{
31-
$schema = $this->getSchema('books');
32-
$this->client()->collections->create($schema);
33-
3452
$this->client()->collections['books']->delete();
3553

3654
$this->expectException(ObjectNotFound::class);
37-
3855
$this->client()->collections['books']->retrieve();
3956
}
57+
58+
public function testCanRetrieveAllCollections(): void
59+
{
60+
$response = $this->client()->collections->retrieve();
61+
$this->assertEquals(1, count($response));
62+
}
4063
}

0 commit comments

Comments
 (0)