|
7 | 7 |
|
8 | 8 | class CollectionTest extends TestCase |
9 | 9 | { |
10 | | - public function testCanCreateCollection(): void |
| 10 | + private $createCollectionRes = null; |
| 11 | + |
| 12 | + |
| 13 | + protected function setUp(): void |
11 | 14 | { |
| 15 | + parent::setUp(); |
| 16 | + |
12 | 17 | $schema = $this->getSchema('books'); |
| 18 | + $this->createCollectionRes = $this->client()->collections->create($schema); |
| 19 | + } |
13 | 20 |
|
14 | | - $response = $this->client()->collections->create($schema); |
| 21 | + public function testCanCreateACollection(): void |
| 22 | + { |
| 23 | + $this->assertEquals('books', $this->createCollectionRes['name']); |
| 24 | + } |
15 | 25 |
|
| 26 | + public function testCanRetrieveACollection(): void |
| 27 | + { |
| 28 | + $response = $this->client()->collections['books']->retrieve(); |
16 | 29 | $this->assertEquals('books', $response['name']); |
17 | 30 | } |
18 | 31 |
|
19 | | - public function testCanRetrieveCollection(): void |
| 32 | + public function testCanUpdateACollection(): void |
20 | 33 | { |
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]); |
23 | 45 |
|
24 | 46 | $response = $this->client()->collections['books']->retrieve(); |
25 | | - |
26 | | - $this->assertEquals('books', $response['name']); |
| 47 | + $this->assertEquals(5, count($response['fields'])); |
27 | 48 | } |
28 | 49 |
|
29 | | - public function testCanDeleteCollection(): void |
| 50 | + public function testCanDeleteACollection(): void |
30 | 51 | { |
31 | | - $schema = $this->getSchema('books'); |
32 | | - $this->client()->collections->create($schema); |
33 | | - |
34 | 52 | $this->client()->collections['books']->delete(); |
35 | 53 |
|
36 | 54 | $this->expectException(ObjectNotFound::class); |
37 | | - |
38 | 55 | $this->client()->collections['books']->retrieve(); |
39 | 56 | } |
| 57 | + |
| 58 | + public function testCanRetrieveAllCollections(): void |
| 59 | + { |
| 60 | + $response = $this->client()->collections->retrieve(); |
| 61 | + $this->assertEquals(1, count($response)); |
| 62 | + } |
40 | 63 | } |
0 commit comments