File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments