forked from typesense/typesense-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSynonymSetsTest.php
More file actions
61 lines (49 loc) · 1.68 KB
/
SynonymSetsTest.php
File metadata and controls
61 lines (49 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace Feature;
use Tests\TestCase;
use Typesense\Exceptions\ObjectNotFound;
use Exception;
class SynonymSetsTest extends TestCase
{
private $upsertResponse = null;
private $synonymSets = null;
private $synonymSetData = [
'synonyms' => [
[
'id' => 'dummy',
'synonyms' => ['foo', 'bar', 'baz'],
'root' => '',
],
],
];
protected function setUp(): void
{
parent::setUp();
if (!$this->isV30OrAbove()) {
$this->markTestSkipped('SynonymSets is only supported in Typesense v30+');
}
$this->synonymSets = $this->client()->synonymSets;
$this->upsertResponse = $this->synonymSets->upsert('test-synonym-set', $this->synonymSetData);
}
public function testCanUpsertASynonymSet(): void
{
$this->assertEquals($this->synonymSetData['synonyms'], $this->upsertResponse['synonyms']);
}
public function testCanRetrieveAllSynonymSets(): void
{
$returnData = $this->synonymSets->retrieve();
$this->assertCount(1, $returnData);
}
public function testCanRetrieveASpecificSynonymSet(): void
{
$returnData = $this->synonymSets['test-synonym-set']->retrieve();
$this->assertEquals($this->synonymSetData['synonyms'], $returnData['synonyms']);
}
public function testCanDeleteASynonymSet(): void
{
$returnData = $this->synonymSets['test-synonym-set']->delete();
$this->assertEquals('test-synonym-set', $returnData['name']);
$this->expectException(ObjectNotFound::class);
$this->synonymSets['test-synonym-set']->retrieve();
}
}