From a86501f820f1b6a0dbeeeb787f0d140299e95040 Mon Sep 17 00:00:00 2001 From: Strift Date: Thu, 5 Dec 2024 17:18:29 +0800 Subject: [PATCH 1/6] Update tests for get/update/reset settings --- tests/Settings/SettingsTest.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/Settings/SettingsTest.php b/tests/Settings/SettingsTest.php index 95c5bf6f..e132b0ca 100644 --- a/tests/Settings/SettingsTest.php +++ b/tests/Settings/SettingsTest.php @@ -29,6 +29,8 @@ final class SettingsTest extends TestCase public const DEFAULT_SEARCHABLE_ATTRIBUTES = ['*']; public const DEFAULT_DISPLAYED_ATTRIBUTES = ['*']; + public const DEFAULT_FACET_SEARCH = true; + public const DEFAULT_PREFIX_SEARCH = 'indexingTime'; public function testGetDefaultSettings(): void { @@ -58,7 +60,8 @@ public function testGetDefaultSettings(): void self::assertEmpty($settingA['sortableAttributes']); self::assertIsIterable($settingA['typoTolerance']); self::assertSame(self::DEFAULT_TYPO_TOLERANCE, iterator_to_array($settingA['typoTolerance'])); - + self::assertSame(self::DEFAULT_FACET_SEARCH, $settingA['facetSearch']); + self::assertSame(self::DEFAULT_PREFIX_SEARCH, $settingA['prefixSearch']); self::assertSame(self::DEFAULT_RANKING_RULES, $settingB['rankingRules']); self::assertNull($settingB['distinctAttribute']); self::assertSame(self::DEFAULT_SEARCHABLE_ATTRIBUTES, $settingB['searchableAttributes']); @@ -73,6 +76,8 @@ public function testGetDefaultSettings(): void self::assertEmpty($settingB['sortableAttributes']); self::assertIsIterable($settingB['typoTolerance']); self::assertSame(self::DEFAULT_TYPO_TOLERANCE, iterator_to_array($settingB['typoTolerance'])); + self::assertSame(self::DEFAULT_FACET_SEARCH, $settingB['facetSearch']); + self::assertSame(self::DEFAULT_PREFIX_SEARCH, $settingB['prefixSearch']); } public function testUpdateSettings(): void @@ -82,6 +87,8 @@ public function testUpdateSettings(): void 'distinctAttribute' => 'title', 'rankingRules' => ['title:asc', 'typo'], 'stopWords' => ['the'], + 'facetSearch' => false, + 'prefixSearch' => 'disabled', ]); $this->assertIsValidPromise($promise); $index->waitForTask($promise['taskUid']); @@ -102,6 +109,8 @@ public function testUpdateSettings(): void self::assertIsArray($settings['sortableAttributes']); self::assertEmpty($settings['sortableAttributes']); self::assertSame(self::DEFAULT_TYPO_TOLERANCE, iterator_to_array($settings['typoTolerance'])); + self::assertSame(false, $settings['facetSearch']); + self::assertSame('disabled', $settings['prefixSearch']); } public function testUpdateSettingsWithoutOverwritingThem(): void @@ -184,6 +193,8 @@ public function testResetSettings(): void self::assertIsArray($settings['sortableAttributes']); self::assertEmpty($settings['sortableAttributes']); self::assertSame(self::DEFAULT_TYPO_TOLERANCE, iterator_to_array($settings['typoTolerance'])); + self::assertSame(self::DEFAULT_FACET_SEARCH, $settings['facetSearch']); + self::assertSame(self::DEFAULT_PREFIX_SEARCH, $settings['prefixSearch']); } // Here the test to prevent https://github.com/meilisearch/meilisearch-php/issues/204. From a321f2ddcd2173527ca55f1154d000e64c681604 Mon Sep 17 00:00:00 2001 From: Strift Date: Thu, 5 Dec 2024 17:25:40 +0800 Subject: [PATCH 2/6] Add get/update/reset methods for facet search settings --- src/Endpoints/Delegates/HandlesSettings.php | 125 +++++++++++--------- tests/Settings/FacetSearchTest.php | 49 ++++++++ 2 files changed, 120 insertions(+), 54 deletions(-) create mode 100644 tests/Settings/FacetSearchTest.php diff --git a/src/Endpoints/Delegates/HandlesSettings.php b/src/Endpoints/Delegates/HandlesSettings.php index a4dec7ef..c7dca337 100644 --- a/src/Endpoints/Delegates/HandlesSettings.php +++ b/src/Endpoints/Delegates/HandlesSettings.php @@ -17,7 +17,7 @@ trait HandlesSettings */ public function getRankingRules(): array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/ranking-rules'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/ranking-rules'); } /** @@ -25,12 +25,12 @@ public function getRankingRules(): array */ public function updateRankingRules(array $rankingRules): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/ranking-rules', $rankingRules); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/ranking-rules', $rankingRules); } public function resetRankingRules(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/ranking-rules'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/ranking-rules'); } // Settings - Distinct attribute @@ -40,7 +40,7 @@ public function resetRankingRules(): array */ public function getDistinctAttribute(): ?string { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/distinct-attribute'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/distinct-attribute'); } /** @@ -48,12 +48,12 @@ public function getDistinctAttribute(): ?string */ public function updateDistinctAttribute(string $distinctAttribute): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/distinct-attribute', $distinctAttribute); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/distinct-attribute', $distinctAttribute); } public function resetDistinctAttribute(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/distinct-attribute'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/distinct-attribute'); } // Settings - Searchable attributes @@ -63,7 +63,7 @@ public function resetDistinctAttribute(): array */ public function getSearchableAttributes(): array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/searchable-attributes'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/searchable-attributes'); } /** @@ -71,12 +71,12 @@ public function getSearchableAttributes(): array */ public function updateSearchableAttributes(array $searchableAttributes): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/searchable-attributes', $searchableAttributes); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/searchable-attributes', $searchableAttributes); } public function resetSearchableAttributes(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/searchable-attributes'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/searchable-attributes'); } // Settings - Displayed attributes @@ -86,7 +86,7 @@ public function resetSearchableAttributes(): array */ public function getDisplayedAttributes(): array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/displayed-attributes'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/displayed-attributes'); } /** @@ -94,12 +94,12 @@ public function getDisplayedAttributes(): array */ public function updateDisplayedAttributes(array $displayedAttributes): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/displayed-attributes', $displayedAttributes); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/displayed-attributes', $displayedAttributes); } public function resetDisplayedAttributes(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/displayed-attributes'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/displayed-attributes'); } // Settings - Localized attributes @@ -109,7 +109,7 @@ public function resetDisplayedAttributes(): array */ public function getLocalizedAttributes(): ?array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/localized-attributes'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/localized-attributes'); } /** @@ -117,12 +117,12 @@ public function getLocalizedAttributes(): ?array */ public function updateLocalizedAttributes(array $localizedAttributes): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/localized-attributes', $localizedAttributes); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/localized-attributes', $localizedAttributes); } public function resetLocalizedAttributes(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/localized-attributes'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/localized-attributes'); } // Settings - Faceting @@ -132,7 +132,7 @@ public function resetLocalizedAttributes(): array */ public function getFaceting(): array { - return (new Faceting($this->http->get(self::PATH.'/'.$this->uid.'/settings/faceting'))) + return (new Faceting($this->http->get(self::PATH . '/' . $this->uid . '/settings/faceting'))) ->getIterator()->getArrayCopy(); } @@ -141,12 +141,12 @@ public function getFaceting(): array */ public function updateFaceting(array $faceting): array { - return $this->http->patch(self::PATH.'/'.$this->uid.'/settings/faceting', $faceting); + return $this->http->patch(self::PATH . '/' . $this->uid . '/settings/faceting', $faceting); } public function resetFaceting(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/faceting'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/faceting'); } // Settings - Pagination @@ -156,7 +156,7 @@ public function resetFaceting(): array */ public function getPagination(): array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/pagination'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/pagination'); } /** @@ -164,12 +164,12 @@ public function getPagination(): array */ public function updatePagination(array $pagination): array { - return $this->http->patch(self::PATH.'/'.$this->uid.'/settings/pagination', $pagination); + return $this->http->patch(self::PATH . '/' . $this->uid . '/settings/pagination', $pagination); } public function resetPagination(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/pagination'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/pagination'); } // Settings - Stop-words @@ -179,7 +179,7 @@ public function resetPagination(): array */ public function getStopWords(): array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/stop-words'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/stop-words'); } /** @@ -187,12 +187,12 @@ public function getStopWords(): array */ public function updateStopWords(array $stopWords): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/stop-words', $stopWords); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/stop-words', $stopWords); } public function resetStopWords(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/stop-words'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/stop-words'); } // Settings - Synonyms @@ -202,7 +202,7 @@ public function resetStopWords(): array */ public function getSynonyms(): array { - return (new Synonyms($this->http->get(self::PATH.'/'.$this->uid.'/settings/synonyms'))) + return (new Synonyms($this->http->get(self::PATH . '/' . $this->uid . '/settings/synonyms'))) ->getIterator()->getArrayCopy(); } @@ -211,12 +211,12 @@ public function getSynonyms(): array */ public function updateSynonyms(array $synonyms): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/synonyms', new Synonyms($synonyms)); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/synonyms', new Synonyms($synonyms)); } public function resetSynonyms(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/synonyms'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/synonyms'); } // Settings - Filterable Attributes @@ -226,7 +226,7 @@ public function resetSynonyms(): array */ public function getFilterableAttributes(): array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/filterable-attributes'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/filterable-attributes'); } /** @@ -234,12 +234,12 @@ public function getFilterableAttributes(): array */ public function updateFilterableAttributes(array $filterableAttributes): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/filterable-attributes', $filterableAttributes); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/filterable-attributes', $filterableAttributes); } public function resetFilterableAttributes(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/filterable-attributes'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/filterable-attributes'); } // Settings - Sortable Attributes @@ -249,7 +249,7 @@ public function resetFilterableAttributes(): array */ public function getSortableAttributes(): array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/sortable-attributes'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/sortable-attributes'); } /** @@ -257,12 +257,12 @@ public function getSortableAttributes(): array */ public function updateSortableAttributes(array $sortableAttributes): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/sortable-attributes', $sortableAttributes); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/sortable-attributes', $sortableAttributes); } public function resetSortableAttributes(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/sortable-attributes'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/sortable-attributes'); } // Settings - Typo Tolerance @@ -277,7 +277,7 @@ public function resetSortableAttributes(): array */ public function getTypoTolerance(): array { - return (new TypoTolerance($this->http->get(self::PATH.'/'.$this->uid.'/settings/typo-tolerance'))) + return (new TypoTolerance($this->http->get(self::PATH . '/' . $this->uid . '/settings/typo-tolerance'))) ->getIterator()->getArrayCopy(); } @@ -291,12 +291,12 @@ public function getTypoTolerance(): array */ public function updateTypoTolerance(array $typoTolerance): array { - return $this->http->patch(self::PATH.'/'.$this->uid.'/settings/typo-tolerance', new TypoTolerance($typoTolerance)); + return $this->http->patch(self::PATH . '/' . $this->uid . '/settings/typo-tolerance', new TypoTolerance($typoTolerance)); } public function resetTypoTolerance(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/typo-tolerance'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/typo-tolerance'); } // Settings - Word dictionary @@ -306,7 +306,7 @@ public function resetTypoTolerance(): array */ public function getDictionary(): array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/dictionary'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/dictionary'); } /** @@ -314,19 +314,19 @@ public function getDictionary(): array */ public function updateDictionary(array $wordDictionary): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/dictionary', $wordDictionary); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/dictionary', $wordDictionary); } public function resetDictionary(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/dictionary'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/dictionary'); } // Settings - Separator tokens public function getSeparatorTokens(): array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/separator-tokens'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/separator-tokens'); } /** @@ -334,12 +334,12 @@ public function getSeparatorTokens(): array */ public function updateSeparatorTokens(array $separatorTokens): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/separator-tokens', $separatorTokens); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/separator-tokens', $separatorTokens); } public function resetSeparatorTokens(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/separator-tokens'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/separator-tokens'); } // Settings - Non-Separator tokens @@ -349,7 +349,7 @@ public function resetSeparatorTokens(): array */ public function getNonSeparatorTokens(): array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/non-separator-tokens'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/non-separator-tokens'); } /** @@ -357,12 +357,12 @@ public function getNonSeparatorTokens(): array */ public function updateNonSeparatorTokens(array $nonSeparatorTokens): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/non-separator-tokens', $nonSeparatorTokens); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/non-separator-tokens', $nonSeparatorTokens); } public function resetNonSeparatorTokens(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/non-separator-tokens'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/non-separator-tokens'); } // Settings - proximityPrecision @@ -372,7 +372,7 @@ public function resetNonSeparatorTokens(): array */ public function getProximityPrecision(): string { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/proximity-precision'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/proximity-precision'); } /** @@ -380,45 +380,62 @@ public function getProximityPrecision(): string */ public function updateProximityPrecision(string $type): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/proximity-precision', $type); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/proximity-precision', $type); } public function resetProximityPrecision(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/proximity-precision'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/proximity-precision'); } // Settings - searchCutoffMs public function getSearchCutoffMs(): ?int { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/search-cutoff-ms'); } public function updateSearchCutoffMs(int $value): array { - return $this->http->put(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms', $value); + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/search-cutoff-ms', $value); } public function resetSearchCutoffMs(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/search-cutoff-ms'); } // Settings - Experimental: Embedders (hybrid search) public function getEmbedders(): ?array { - return $this->http->get(self::PATH.'/'.$this->uid.'/settings/embedders'); + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/embedders'); } public function updateEmbedders(array $embedders): array { - return $this->http->patch(self::PATH.'/'.$this->uid.'/settings/embedders', $embedders); + return $this->http->patch(self::PATH . '/' . $this->uid . '/settings/embedders', $embedders); } public function resetEmbedders(): array { - return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/embedders'); + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/embedders'); + } + + // Settings - Facet Search + + public function getFacetSearch(): bool + { + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/facet-search'); + } + + public function updateFacetSearch(bool $facetSearch): array + { + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/facet-search', $facetSearch); + } + + public function resetFacetSearch(): array + { + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/facet-search'); } } diff --git a/tests/Settings/FacetSearchTest.php b/tests/Settings/FacetSearchTest.php new file mode 100644 index 00000000..765a78e1 --- /dev/null +++ b/tests/Settings/FacetSearchTest.php @@ -0,0 +1,49 @@ +createEmptyIndex($this->safeIndexName()); + + $facetSearch = $index->getFacetSearch(); + + self::assertTrue($facetSearch); + } + + public function testUpdateFacetSearch(): void + { + $index = $this->createEmptyIndex($this->safeIndexName()); + + $promise = $index->updateFacetSearch(false); + + $this->assertIsValidPromise($promise); + $index->waitForTask($promise['taskUid']); + + $facetSearch = $index->getFacetSearch(); + self::assertFalse($facetSearch); + } + + public function testResetFacetSearch(): void + { + $index = $this->createEmptyIndex($this->safeIndexName()); + + $promise = $index->updateFacetSearch(false); + $index->waitForTask($promise['taskUid']); + + $promise = $index->resetFacetSearch(); + + $this->assertIsValidPromise($promise); + + $index->waitForTask($promise['taskUid']); + + $facetSearch = $index->getFacetSearch(); + self::assertTrue($facetSearch); + } +} From bca115765f3e4e69cf2701b093ce6705e6ee6a6e Mon Sep 17 00:00:00 2001 From: Strift Date: Thu, 5 Dec 2024 17:35:40 +0800 Subject: [PATCH 3/6] Add get/update/reset methods for prefix search settings --- src/Endpoints/Delegates/HandlesSettings.php | 23 ++++++++++ tests/Settings/PrefixSearchTest.php | 49 +++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 tests/Settings/PrefixSearchTest.php diff --git a/src/Endpoints/Delegates/HandlesSettings.php b/src/Endpoints/Delegates/HandlesSettings.php index c7dca337..d4c03c56 100644 --- a/src/Endpoints/Delegates/HandlesSettings.php +++ b/src/Endpoints/Delegates/HandlesSettings.php @@ -438,4 +438,27 @@ public function resetFacetSearch(): array { return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/facet-search'); } + + // Settings - Prefix Search + + /** + * @return 'indexingTime'|'disabled' + */ + public function getPrefixSearch(): string + { + return $this->http->get(self::PATH . '/' . $this->uid . '/settings/prefix-search'); + } + + /** + * @param 'indexingTime'|'disabled' $prefixSearch + */ + public function updatePrefixSearch(string $prefixSearch): array + { + return $this->http->put(self::PATH . '/' . $this->uid . '/settings/prefix-search', $prefixSearch); + } + + public function resetPrefixSearch(): array + { + return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/prefix-search'); + } } diff --git a/tests/Settings/PrefixSearchTest.php b/tests/Settings/PrefixSearchTest.php new file mode 100644 index 00000000..ae511813 --- /dev/null +++ b/tests/Settings/PrefixSearchTest.php @@ -0,0 +1,49 @@ +createEmptyIndex($this->safeIndexName()); + + $prefixSearch = $index->getPrefixSearch(); + + self::assertSame('indexingTime', $prefixSearch); + } + + public function testUpdatePrefixSearch(): void + { + $index = $this->createEmptyIndex($this->safeIndexName()); + + $promise = $index->updatePrefixSearch('disabled'); + + $this->assertIsValidPromise($promise); + $index->waitForTask($promise['taskUid']); + + $prefixSearch = $index->getPrefixSearch(); + self::assertSame('disabled', $prefixSearch); + } + + public function testResetPrefixSearch(): void + { + $index = $this->createEmptyIndex($this->safeIndexName()); + + $promise = $index->updatePrefixSearch('disabled'); + $index->waitForTask($promise['taskUid']); + + $promise = $index->resetPrefixSearch(); + + $this->assertIsValidPromise($promise); + + $index->waitForTask($promise['taskUid']); + + $prefixSearch = $index->getPrefixSearch(); + self::assertSame('indexingTime', $prefixSearch); + } +} From 76df31b4d0c6f330f4999e3714e0f9906c6c164d Mon Sep 17 00:00:00 2001 From: Strift Date: Thu, 5 Dec 2024 17:42:18 +0800 Subject: [PATCH 4/6] Add Meilisearch version requirement in documentation --- src/Endpoints/Delegates/HandlesSettings.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Endpoints/Delegates/HandlesSettings.php b/src/Endpoints/Delegates/HandlesSettings.php index d4c03c56..bf32c1cb 100644 --- a/src/Endpoints/Delegates/HandlesSettings.php +++ b/src/Endpoints/Delegates/HandlesSettings.php @@ -424,16 +424,27 @@ public function resetEmbedders(): array // Settings - Facet Search + /** + * @return bool + * @since Meilisearch v1.12.0 + */ public function getFacetSearch(): bool { return $this->http->get(self::PATH . '/' . $this->uid . '/settings/facet-search'); } + /** + * @param bool $facetSearch + * @since Meilisearch v1.12.0 + */ public function updateFacetSearch(bool $facetSearch): array { return $this->http->put(self::PATH . '/' . $this->uid . '/settings/facet-search', $facetSearch); } + /** + * @since Meilisearch v1.12.0 + */ public function resetFacetSearch(): array { return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/facet-search'); @@ -443,6 +454,7 @@ public function resetFacetSearch(): array /** * @return 'indexingTime'|'disabled' + * @since Meilisearch v1.12.0 */ public function getPrefixSearch(): string { @@ -451,12 +463,16 @@ public function getPrefixSearch(): string /** * @param 'indexingTime'|'disabled' $prefixSearch + * @since Meilisearch v1.12.0 */ public function updatePrefixSearch(string $prefixSearch): array { return $this->http->put(self::PATH . '/' . $this->uid . '/settings/prefix-search', $prefixSearch); } + /** + * @since Meilisearch v1.12.0 + */ public function resetPrefixSearch(): array { return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/prefix-search'); From 9e22f042343d70d0ad82f98ffbfd348b5964dd29 Mon Sep 17 00:00:00 2001 From: Strift Date: Thu, 5 Dec 2024 17:45:17 +0800 Subject: [PATCH 5/6] Run lint:fix --- src/Endpoints/Delegates/HandlesSettings.php | 124 ++++++++++---------- tests/Settings/FacetSearchTest.php | 52 ++++---- tests/Settings/PrefixSearchTest.php | 52 ++++---- 3 files changed, 114 insertions(+), 114 deletions(-) diff --git a/src/Endpoints/Delegates/HandlesSettings.php b/src/Endpoints/Delegates/HandlesSettings.php index bf32c1cb..88afe17c 100644 --- a/src/Endpoints/Delegates/HandlesSettings.php +++ b/src/Endpoints/Delegates/HandlesSettings.php @@ -17,7 +17,7 @@ trait HandlesSettings */ public function getRankingRules(): array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/ranking-rules'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/ranking-rules'); } /** @@ -25,12 +25,12 @@ public function getRankingRules(): array */ public function updateRankingRules(array $rankingRules): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/ranking-rules', $rankingRules); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/ranking-rules', $rankingRules); } public function resetRankingRules(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/ranking-rules'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/ranking-rules'); } // Settings - Distinct attribute @@ -40,7 +40,7 @@ public function resetRankingRules(): array */ public function getDistinctAttribute(): ?string { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/distinct-attribute'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/distinct-attribute'); } /** @@ -48,12 +48,12 @@ public function getDistinctAttribute(): ?string */ public function updateDistinctAttribute(string $distinctAttribute): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/distinct-attribute', $distinctAttribute); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/distinct-attribute', $distinctAttribute); } public function resetDistinctAttribute(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/distinct-attribute'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/distinct-attribute'); } // Settings - Searchable attributes @@ -63,7 +63,7 @@ public function resetDistinctAttribute(): array */ public function getSearchableAttributes(): array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/searchable-attributes'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/searchable-attributes'); } /** @@ -71,12 +71,12 @@ public function getSearchableAttributes(): array */ public function updateSearchableAttributes(array $searchableAttributes): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/searchable-attributes', $searchableAttributes); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/searchable-attributes', $searchableAttributes); } public function resetSearchableAttributes(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/searchable-attributes'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/searchable-attributes'); } // Settings - Displayed attributes @@ -86,7 +86,7 @@ public function resetSearchableAttributes(): array */ public function getDisplayedAttributes(): array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/displayed-attributes'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/displayed-attributes'); } /** @@ -94,12 +94,12 @@ public function getDisplayedAttributes(): array */ public function updateDisplayedAttributes(array $displayedAttributes): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/displayed-attributes', $displayedAttributes); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/displayed-attributes', $displayedAttributes); } public function resetDisplayedAttributes(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/displayed-attributes'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/displayed-attributes'); } // Settings - Localized attributes @@ -109,7 +109,7 @@ public function resetDisplayedAttributes(): array */ public function getLocalizedAttributes(): ?array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/localized-attributes'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/localized-attributes'); } /** @@ -117,12 +117,12 @@ public function getLocalizedAttributes(): ?array */ public function updateLocalizedAttributes(array $localizedAttributes): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/localized-attributes', $localizedAttributes); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/localized-attributes', $localizedAttributes); } public function resetLocalizedAttributes(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/localized-attributes'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/localized-attributes'); } // Settings - Faceting @@ -132,7 +132,7 @@ public function resetLocalizedAttributes(): array */ public function getFaceting(): array { - return (new Faceting($this->http->get(self::PATH . '/' . $this->uid . '/settings/faceting'))) + return (new Faceting($this->http->get(self::PATH.'/'.$this->uid.'/settings/faceting'))) ->getIterator()->getArrayCopy(); } @@ -141,12 +141,12 @@ public function getFaceting(): array */ public function updateFaceting(array $faceting): array { - return $this->http->patch(self::PATH . '/' . $this->uid . '/settings/faceting', $faceting); + return $this->http->patch(self::PATH.'/'.$this->uid.'/settings/faceting', $faceting); } public function resetFaceting(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/faceting'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/faceting'); } // Settings - Pagination @@ -156,7 +156,7 @@ public function resetFaceting(): array */ public function getPagination(): array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/pagination'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/pagination'); } /** @@ -164,12 +164,12 @@ public function getPagination(): array */ public function updatePagination(array $pagination): array { - return $this->http->patch(self::PATH . '/' . $this->uid . '/settings/pagination', $pagination); + return $this->http->patch(self::PATH.'/'.$this->uid.'/settings/pagination', $pagination); } public function resetPagination(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/pagination'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/pagination'); } // Settings - Stop-words @@ -179,7 +179,7 @@ public function resetPagination(): array */ public function getStopWords(): array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/stop-words'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/stop-words'); } /** @@ -187,12 +187,12 @@ public function getStopWords(): array */ public function updateStopWords(array $stopWords): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/stop-words', $stopWords); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/stop-words', $stopWords); } public function resetStopWords(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/stop-words'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/stop-words'); } // Settings - Synonyms @@ -202,7 +202,7 @@ public function resetStopWords(): array */ public function getSynonyms(): array { - return (new Synonyms($this->http->get(self::PATH . '/' . $this->uid . '/settings/synonyms'))) + return (new Synonyms($this->http->get(self::PATH.'/'.$this->uid.'/settings/synonyms'))) ->getIterator()->getArrayCopy(); } @@ -211,12 +211,12 @@ public function getSynonyms(): array */ public function updateSynonyms(array $synonyms): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/synonyms', new Synonyms($synonyms)); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/synonyms', new Synonyms($synonyms)); } public function resetSynonyms(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/synonyms'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/synonyms'); } // Settings - Filterable Attributes @@ -226,7 +226,7 @@ public function resetSynonyms(): array */ public function getFilterableAttributes(): array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/filterable-attributes'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/filterable-attributes'); } /** @@ -234,12 +234,12 @@ public function getFilterableAttributes(): array */ public function updateFilterableAttributes(array $filterableAttributes): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/filterable-attributes', $filterableAttributes); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/filterable-attributes', $filterableAttributes); } public function resetFilterableAttributes(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/filterable-attributes'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/filterable-attributes'); } // Settings - Sortable Attributes @@ -249,7 +249,7 @@ public function resetFilterableAttributes(): array */ public function getSortableAttributes(): array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/sortable-attributes'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/sortable-attributes'); } /** @@ -257,12 +257,12 @@ public function getSortableAttributes(): array */ public function updateSortableAttributes(array $sortableAttributes): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/sortable-attributes', $sortableAttributes); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/sortable-attributes', $sortableAttributes); } public function resetSortableAttributes(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/sortable-attributes'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/sortable-attributes'); } // Settings - Typo Tolerance @@ -277,7 +277,7 @@ public function resetSortableAttributes(): array */ public function getTypoTolerance(): array { - return (new TypoTolerance($this->http->get(self::PATH . '/' . $this->uid . '/settings/typo-tolerance'))) + return (new TypoTolerance($this->http->get(self::PATH.'/'.$this->uid.'/settings/typo-tolerance'))) ->getIterator()->getArrayCopy(); } @@ -291,12 +291,12 @@ public function getTypoTolerance(): array */ public function updateTypoTolerance(array $typoTolerance): array { - return $this->http->patch(self::PATH . '/' . $this->uid . '/settings/typo-tolerance', new TypoTolerance($typoTolerance)); + return $this->http->patch(self::PATH.'/'.$this->uid.'/settings/typo-tolerance', new TypoTolerance($typoTolerance)); } public function resetTypoTolerance(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/typo-tolerance'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/typo-tolerance'); } // Settings - Word dictionary @@ -306,7 +306,7 @@ public function resetTypoTolerance(): array */ public function getDictionary(): array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/dictionary'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/dictionary'); } /** @@ -314,19 +314,19 @@ public function getDictionary(): array */ public function updateDictionary(array $wordDictionary): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/dictionary', $wordDictionary); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/dictionary', $wordDictionary); } public function resetDictionary(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/dictionary'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/dictionary'); } // Settings - Separator tokens public function getSeparatorTokens(): array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/separator-tokens'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/separator-tokens'); } /** @@ -334,12 +334,12 @@ public function getSeparatorTokens(): array */ public function updateSeparatorTokens(array $separatorTokens): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/separator-tokens', $separatorTokens); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/separator-tokens', $separatorTokens); } public function resetSeparatorTokens(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/separator-tokens'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/separator-tokens'); } // Settings - Non-Separator tokens @@ -349,7 +349,7 @@ public function resetSeparatorTokens(): array */ public function getNonSeparatorTokens(): array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/non-separator-tokens'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/non-separator-tokens'); } /** @@ -357,12 +357,12 @@ public function getNonSeparatorTokens(): array */ public function updateNonSeparatorTokens(array $nonSeparatorTokens): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/non-separator-tokens', $nonSeparatorTokens); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/non-separator-tokens', $nonSeparatorTokens); } public function resetNonSeparatorTokens(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/non-separator-tokens'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/non-separator-tokens'); } // Settings - proximityPrecision @@ -372,7 +372,7 @@ public function resetNonSeparatorTokens(): array */ public function getProximityPrecision(): string { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/proximity-precision'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/proximity-precision'); } /** @@ -380,66 +380,64 @@ public function getProximityPrecision(): string */ public function updateProximityPrecision(string $type): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/proximity-precision', $type); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/proximity-precision', $type); } public function resetProximityPrecision(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/proximity-precision'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/proximity-precision'); } // Settings - searchCutoffMs public function getSearchCutoffMs(): ?int { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/search-cutoff-ms'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms'); } public function updateSearchCutoffMs(int $value): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/search-cutoff-ms', $value); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms', $value); } public function resetSearchCutoffMs(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/search-cutoff-ms'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms'); } // Settings - Experimental: Embedders (hybrid search) public function getEmbedders(): ?array { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/embedders'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/embedders'); } public function updateEmbedders(array $embedders): array { - return $this->http->patch(self::PATH . '/' . $this->uid . '/settings/embedders', $embedders); + return $this->http->patch(self::PATH.'/'.$this->uid.'/settings/embedders', $embedders); } public function resetEmbedders(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/embedders'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/embedders'); } // Settings - Facet Search /** - * @return bool * @since Meilisearch v1.12.0 */ public function getFacetSearch(): bool { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/facet-search'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/facet-search'); } /** - * @param bool $facetSearch * @since Meilisearch v1.12.0 */ public function updateFacetSearch(bool $facetSearch): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/facet-search', $facetSearch); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/facet-search', $facetSearch); } /** @@ -447,27 +445,29 @@ public function updateFacetSearch(bool $facetSearch): array */ public function resetFacetSearch(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/facet-search'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/facet-search'); } // Settings - Prefix Search /** * @return 'indexingTime'|'disabled' + * * @since Meilisearch v1.12.0 */ public function getPrefixSearch(): string { - return $this->http->get(self::PATH . '/' . $this->uid . '/settings/prefix-search'); + return $this->http->get(self::PATH.'/'.$this->uid.'/settings/prefix-search'); } /** * @param 'indexingTime'|'disabled' $prefixSearch + * * @since Meilisearch v1.12.0 */ public function updatePrefixSearch(string $prefixSearch): array { - return $this->http->put(self::PATH . '/' . $this->uid . '/settings/prefix-search', $prefixSearch); + return $this->http->put(self::PATH.'/'.$this->uid.'/settings/prefix-search', $prefixSearch); } /** @@ -475,6 +475,6 @@ public function updatePrefixSearch(string $prefixSearch): array */ public function resetPrefixSearch(): array { - return $this->http->delete(self::PATH . '/' . $this->uid . '/settings/prefix-search'); + return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/prefix-search'); } } diff --git a/tests/Settings/FacetSearchTest.php b/tests/Settings/FacetSearchTest.php index 765a78e1..ae05199b 100644 --- a/tests/Settings/FacetSearchTest.php +++ b/tests/Settings/FacetSearchTest.php @@ -8,42 +8,42 @@ final class FacetSearchTest extends TestCase { - public function testGetDefaultFacetSearch(): void - { - $index = $this->createEmptyIndex($this->safeIndexName()); + public function testGetDefaultFacetSearch(): void + { + $index = $this->createEmptyIndex($this->safeIndexName()); - $facetSearch = $index->getFacetSearch(); + $facetSearch = $index->getFacetSearch(); - self::assertTrue($facetSearch); - } + self::assertTrue($facetSearch); + } - public function testUpdateFacetSearch(): void - { - $index = $this->createEmptyIndex($this->safeIndexName()); + public function testUpdateFacetSearch(): void + { + $index = $this->createEmptyIndex($this->safeIndexName()); - $promise = $index->updateFacetSearch(false); + $promise = $index->updateFacetSearch(false); - $this->assertIsValidPromise($promise); - $index->waitForTask($promise['taskUid']); + $this->assertIsValidPromise($promise); + $index->waitForTask($promise['taskUid']); - $facetSearch = $index->getFacetSearch(); - self::assertFalse($facetSearch); - } + $facetSearch = $index->getFacetSearch(); + self::assertFalse($facetSearch); + } - public function testResetFacetSearch(): void - { - $index = $this->createEmptyIndex($this->safeIndexName()); + public function testResetFacetSearch(): void + { + $index = $this->createEmptyIndex($this->safeIndexName()); - $promise = $index->updateFacetSearch(false); - $index->waitForTask($promise['taskUid']); + $promise = $index->updateFacetSearch(false); + $index->waitForTask($promise['taskUid']); - $promise = $index->resetFacetSearch(); + $promise = $index->resetFacetSearch(); - $this->assertIsValidPromise($promise); + $this->assertIsValidPromise($promise); - $index->waitForTask($promise['taskUid']); + $index->waitForTask($promise['taskUid']); - $facetSearch = $index->getFacetSearch(); - self::assertTrue($facetSearch); - } + $facetSearch = $index->getFacetSearch(); + self::assertTrue($facetSearch); + } } diff --git a/tests/Settings/PrefixSearchTest.php b/tests/Settings/PrefixSearchTest.php index ae511813..2e93bd93 100644 --- a/tests/Settings/PrefixSearchTest.php +++ b/tests/Settings/PrefixSearchTest.php @@ -8,42 +8,42 @@ final class PrefixSearchTest extends TestCase { - public function testGetDefaultPrefixSearch(): void - { - $index = $this->createEmptyIndex($this->safeIndexName()); + public function testGetDefaultPrefixSearch(): void + { + $index = $this->createEmptyIndex($this->safeIndexName()); - $prefixSearch = $index->getPrefixSearch(); + $prefixSearch = $index->getPrefixSearch(); - self::assertSame('indexingTime', $prefixSearch); - } + self::assertSame('indexingTime', $prefixSearch); + } - public function testUpdatePrefixSearch(): void - { - $index = $this->createEmptyIndex($this->safeIndexName()); + public function testUpdatePrefixSearch(): void + { + $index = $this->createEmptyIndex($this->safeIndexName()); - $promise = $index->updatePrefixSearch('disabled'); + $promise = $index->updatePrefixSearch('disabled'); - $this->assertIsValidPromise($promise); - $index->waitForTask($promise['taskUid']); + $this->assertIsValidPromise($promise); + $index->waitForTask($promise['taskUid']); - $prefixSearch = $index->getPrefixSearch(); - self::assertSame('disabled', $prefixSearch); - } + $prefixSearch = $index->getPrefixSearch(); + self::assertSame('disabled', $prefixSearch); + } - public function testResetPrefixSearch(): void - { - $index = $this->createEmptyIndex($this->safeIndexName()); + public function testResetPrefixSearch(): void + { + $index = $this->createEmptyIndex($this->safeIndexName()); - $promise = $index->updatePrefixSearch('disabled'); - $index->waitForTask($promise['taskUid']); + $promise = $index->updatePrefixSearch('disabled'); + $index->waitForTask($promise['taskUid']); - $promise = $index->resetPrefixSearch(); + $promise = $index->resetPrefixSearch(); - $this->assertIsValidPromise($promise); + $this->assertIsValidPromise($promise); - $index->waitForTask($promise['taskUid']); + $index->waitForTask($promise['taskUid']); - $prefixSearch = $index->getPrefixSearch(); - self::assertSame('indexingTime', $prefixSearch); - } + $prefixSearch = $index->getPrefixSearch(); + self::assertSame('indexingTime', $prefixSearch); + } } From a05224a0b093176b18a75174ec1e6303c1ce4c1f Mon Sep 17 00:00:00 2001 From: Strift Date: Thu, 5 Dec 2024 17:48:49 +0800 Subject: [PATCH 6/6] Update assertion --- tests/Settings/SettingsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Settings/SettingsTest.php b/tests/Settings/SettingsTest.php index e132b0ca..36b52179 100644 --- a/tests/Settings/SettingsTest.php +++ b/tests/Settings/SettingsTest.php @@ -109,7 +109,7 @@ public function testUpdateSettings(): void self::assertIsArray($settings['sortableAttributes']); self::assertEmpty($settings['sortableAttributes']); self::assertSame(self::DEFAULT_TYPO_TOLERANCE, iterator_to_array($settings['typoTolerance'])); - self::assertSame(false, $settings['facetSearch']); + self::assertFalse($settings['facetSearch']); self::assertSame('disabled', $settings['prefixSearch']); }