Skip to content

Commit 8c07790

Browse files
committed
test: key
1 parent 9a865aa commit 8c07790

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

tests/Feature/KeyTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Feature;
4+
5+
use Tests\TestCase;
6+
use Typesense\Exceptions\ObjectNotFound;
7+
8+
9+
class KeyTest extends TestCase
10+
{
11+
private $keyId = null;
12+
13+
protected function setUp(): void
14+
{
15+
parent::setUp();
16+
17+
$response = $this->client()->keys->create([
18+
'description' => 'Admin key.',
19+
'actions' => ['*'],
20+
'collections' => ['*']
21+
]);;
22+
$this->keyId = $response['id'];
23+
$this->assertEquals($response['description'], 'Admin key.');
24+
}
25+
26+
public function testCanRetrieveAKey(): void
27+
{
28+
$key = $this->client()->keys[$this->keyId]->retrieve();
29+
30+
$this->assertEquals($key['id'], $this->keyId);
31+
}
32+
33+
public function testCanDeleteAKey(): void
34+
{
35+
$key = $this->client()->keys[$this->keyId]->delete();
36+
$this->assertEquals($key['id'], $this->keyId);
37+
38+
$this->expectException(ObjectNotFound::class);
39+
$key = $this->client()->keys[$this->keyId]->retrieve();
40+
}
41+
}

0 commit comments

Comments
 (0)