Skip to content

Commit 99a08a1

Browse files
committed
test: stopwords
1 parent a4a2412 commit 99a08a1

2 files changed

Lines changed: 60 additions & 1 deletion

File tree

tests/Feature/OverrideTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testCanDeleteAnOverride(): void
5656

5757
public function testCanRetrieveAllOverrides(): void
5858
{
59-
$returnData = $this->client()->collections['books']->overrides->retrieve();;
59+
$returnData = $this->client()->collections['books']->overrides->retrieve();
6060
$this->assertEquals(1, count($returnData['overrides']));
6161
}
6262
}

tests/Feature/StopwordsTest.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace Feature;
4+
5+
use Tests\TestCase;
6+
use Typesense\Exceptions\ObjectNotFound;
7+
8+
9+
class StopwordsTest extends TestCase
10+
{
11+
private $stopwordsUpsertRes = null;
12+
13+
protected function setUp(): void
14+
{
15+
parent::setUp();
16+
17+
$this->stopwordsUpsertRes = $this->client()->stopwords->put(
18+
[
19+
"stopwords_name" => "stopword_set1",
20+
"stopwords_data" => ["Germany"],
21+
]
22+
);
23+
}
24+
25+
protected function tearDown(): void
26+
{
27+
$stopwords = $this->client()->stopwords->getAll();
28+
foreach ($stopwords['stopwords'] as $stopword) {
29+
$this->client()->stopwords->delete($stopword['id']);
30+
}
31+
}
32+
33+
public function testCanUpsertAStopword(): void
34+
{
35+
$this->assertEquals("stopword_set1", $this->stopwordsUpsertRes['id']);
36+
$this->assertEquals(["Germany"], $this->stopwordsUpsertRes['stopwords']);
37+
}
38+
39+
public function testCanRetrieveAStopword(): void
40+
{
41+
$returnData = $this->client()->stopwords->get("stopword_set1");
42+
$this->assertEquals("stopword_set1", $returnData['stopwords']['id']);
43+
}
44+
45+
public function testCanDeleteAStopword(): void
46+
{
47+
$returnData = $this->client()->stopwords->delete("stopword_set1");
48+
$this->assertEquals("stopword_set1", $returnData['id']);
49+
50+
$this->expectException(ObjectNotFound::class);
51+
$this->client()->stopwords->get("stopword_set1");
52+
}
53+
54+
public function testCanRetrieveAllStopwords(): void
55+
{
56+
$returnData = $this->client()->stopwords->getAll();
57+
$this->assertEquals(1, count($returnData['stopwords']));
58+
}
59+
}

0 commit comments

Comments
 (0)