Skip to content

Commit f88d50f

Browse files
authored
Merge pull request #70 from phiHero/pr64_add_tests
Add tests for pr #64
2 parents 9a04673 + ffda144 commit f88d50f

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

src/Stopwords.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Typesense\Exceptions\TypesenseClientError;
77

88
/**
9-
* Class Document
9+
* Class Stopwords
1010
*
1111
* @package \Typesense
1212
* @date 4/5/20
@@ -22,7 +22,7 @@ class Stopwords
2222
public const STOPWORDS_PATH = '/stopwords';
2323

2424
/**
25-
* Document constructor.
25+
* Stopwords constructor.
2626
*
2727
* @param ApiCall $apiCall
2828
*/
@@ -43,6 +43,7 @@ public function get(string $stopwordsName)
4343
[]
4444
);
4545
}
46+
4647
/**
4748
* @return array|string
4849
* @throws HttpClientException
@@ -54,32 +55,27 @@ public function getAll()
5455
}
5556

5657
/**
57-
* @param array $options
58+
* @param array $stopwordSet
5859
*
5960
* @return array
6061
* @throws HttpClientException
6162
* @throws TypesenseClientError
6263
*/
63-
public function put(array $options = [])
64+
public function put(array $stopwordSet)
6465
{
65-
$stopwordsName = $options['stopwords_name'];
66-
$stopwordsData = $options['stopwords_data'];
67-
return $this->apiCall->put(
68-
$this->endpointPath($stopwordsName),
69-
['stopwords' => $stopwordsData]
70-
);
66+
return $this->apiCall->put($this->endpointPath($stopwordSet['name']), $stopwordSet);
7167
}
7268

7369
/**
74-
* @param $presetName
70+
* @param $stopwordsName
7571
* @return array
7672
* @throws HttpClientException
7773
* @throws TypesenseClientError
7874
*/
79-
public function delete($presetName)
75+
public function delete($stopwordsName)
8076
{
8177
return $this->apiCall->delete(
82-
$this->endpointPath($presetName)
78+
$this->endpointPath($stopwordsName)
8379
);
8480
}
8581

tests/Feature/StopwordsTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ protected function setUp(): void
1616

1717
$this->stopwordsUpsertRes = $this->client()->stopwords->put(
1818
[
19-
"stopwords_name" => "stopword_set1",
20-
"stopwords_data" => ["Germany"],
19+
"name" => "stopword_set1",
20+
"stopwords" => ["Germany"],
21+
"locale" => "en"
2122
]
2223
);
2324
}
@@ -34,6 +35,7 @@ public function testCanUpsertAStopword(): void
3435
{
3536
$this->assertEquals("stopword_set1", $this->stopwordsUpsertRes['id']);
3637
$this->assertEquals(["Germany"], $this->stopwordsUpsertRes['stopwords']);
38+
$this->assertEquals('en', $this->stopwordsUpsertRes['locale']);
3739
}
3840

3941
public function testCanRetrieveAStopword(): void

0 commit comments

Comments
 (0)