@@ -25,6 +25,14 @@ protected function setUp(): void
2525 $ this ->keyId = $ res ['id ' ];
2626 }
2727
28+ protected function tearDown (): void
29+ {
30+ $ keys = $ this ->client ()->keys ->retrieve ();
31+ foreach ($ keys ['keys ' ] as $ key ) {
32+ $ this ->client ()->keys [$ key ['id ' ]]->delete ();
33+ }
34+ }
35+
2836 public function testCanCreateAKey (): void
2937 {
3038 $ this ->assertEquals ($ this ->createKeyResponse ['description ' ], 'Admin key. ' );
@@ -45,4 +53,24 @@ public function testCanDeleteAKey(): void
4553 $ this ->expectException (ObjectNotFound::class);
4654 $ key = $ this ->client ()->keys [$ this ->keyId ]->retrieve ();
4755 }
56+
57+ public function testCanRetrieveAllKeys (): void
58+ {
59+ $ keys = $ this ->client ()->keys ->retrieve ();
60+ $ this ->assertCount (1 , $ keys ['keys ' ]);
61+ }
62+
63+ public function testCanGenerateScopedSearchKey (): void
64+ {
65+ // The following keys were generated and verified to work with an actual Typesense server
66+ // We're only verifying that the algorithm works as expected client-side
67+ $ searchKey = "RN23GFr1s6jQ9kgSNg2O7fYcAUXU7127 " ;
68+ $ scopedSearchKey =
69+ "SC9sT0hncHFwTHNFc3U3d3psRDZBUGNXQUViQUdDNmRHSmJFQnNnczJ4VT1STjIzeyJmaWx0ZXJfYnkiOiJjb21wYW55X2lkOjEyNCJ9 " ;
70+
71+ $ result = $ this ->client ()->keys ->generateScopedSearchKey ($ searchKey , [
72+ "filter_by " => "company_id:124 " ,
73+ ]);
74+ $ this ->assertEquals ($ scopedSearchKey , $ result );
75+ }
4876}
0 commit comments