forked from typesense/typesense-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSynonymsTest.php
More file actions
57 lines (44 loc) · 1.62 KB
/
SynonymsTest.php
File metadata and controls
57 lines (44 loc) · 1.62 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
<?php
namespace Feature;
use Tests\TestCase;
use Typesense\Exceptions\ObjectNotFound;
class SynonymsTest extends TestCase
{
private $upsertResponse = null;
private $synonyms = null;
private $synonymData = [
"synonyms" => ["blazer", "coat", "jacket"]
];
protected function setUp(): void
{
parent::setUp();
if ($this->isV30OrAbove()) {
$this->markTestSkipped('Synonyms is deprecated in Typesense v30+, use SynonymSets instead');
}
$this->setUpCollection('books');
$this->synonyms = $this->client()->collections['books']->synonyms;
$this->upsertResponse = $this->synonyms->upsert('coat-synonyms', $this->synonymData);
}
public function testCanUpsertASynonym(): void
{
$this->assertEquals('coat-synonyms', $this->upsertResponse['id']);
$this->assertEquals($this->synonymData['synonyms'], $this->upsertResponse['synonyms']);
}
public function testCanRetrieveASynonymById(): void
{
$returnData = $this->synonyms['coat-synonyms']->retrieve();
$this->assertEquals('coat-synonyms', $returnData['id']);
}
public function testCanDeleteASynonymById(): void
{
$returnData = $this->synonyms['coat-synonyms']->delete();
$this->assertEquals('coat-synonyms', $returnData['id']);
$this->expectException(ObjectNotFound::class);
$this->synonyms['coat-synonyms']->retrieve();
}
public function testCanRetrieveAllSynonyms(): void
{
$returnData = $this->synonyms->retrieve();
$this->assertCount(1, $returnData['synonyms']);
}
}