Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for pr #64 #70

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/Stopwords.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Typesense\Exceptions\TypesenseClientError;

/**
* Class Document
* Class Stopwords
*
* @package \Typesense
* @date 4/5/20
Expand All @@ -22,7 +22,7 @@ class Stopwords
public const STOPWORDS_PATH = '/stopwords';

/**
* Document constructor.
* Stopwords constructor.
*
* @param ApiCall $apiCall
*/
Expand All @@ -43,6 +43,7 @@ public function get(string $stopwordsName)
[]
);
}

/**
* @return array|string
* @throws HttpClientException
Expand All @@ -54,32 +55,27 @@ public function getAll()
}

/**
* @param array $options
* @param array $stopwordSet
*
* @return array
* @throws HttpClientException
* @throws TypesenseClientError
*/
public function put(array $options = [])
public function put(array $stopwordSet)
{
$stopwordsName = $options['stopwords_name'];
$stopwordsData = $options['stopwords_data'];
return $this->apiCall->put(
$this->endpointPath($stopwordsName),
['stopwords' => $stopwordsData]
);
return $this->apiCall->put($this->endpointPath($stopwordSet['name']), $stopwordSet);
}

/**
* @param $presetName
* @param $stopwordsName
* @return array
* @throws HttpClientException
* @throws TypesenseClientError
*/
public function delete($presetName)
public function delete($stopwordsName)
{
return $this->apiCall->delete(
$this->endpointPath($presetName)
$this->endpointPath($stopwordsName)
);
}

Expand Down
6 changes: 4 additions & 2 deletions tests/Feature/StopwordsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ protected function setUp(): void

$this->stopwordsUpsertRes = $this->client()->stopwords->put(
[
"stopwords_name" => "stopword_set1",
"stopwords_data" => ["Germany"],
"name" => "stopword_set1",
"stopwords" => ["Germany"],
"locale" => "en"
]
);
}
Expand All @@ -34,6 +35,7 @@ public function testCanUpsertAStopword(): void
{
$this->assertEquals("stopword_set1", $this->stopwordsUpsertRes['id']);
$this->assertEquals(["Germany"], $this->stopwordsUpsertRes['stopwords']);
$this->assertEquals('en', $this->stopwordsUpsertRes['locale']);
}

public function testCanRetrieveAStopword(): void
Expand Down