StopWordsTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. declare(strict_types=1);
  3. namespace Tests\Settings;
  4. use Tests\TestCase;
  5. final class StopWordsTest extends TestCase
  6. {
  7. private $index;
  8. protected function setUp(): void
  9. {
  10. parent::setUp();
  11. $this->index = $this->client->createIndex('index');
  12. }
  13. public function testGetDefaultStopWords(): void
  14. {
  15. $response = $this->index->getStopWords();
  16. $this->assertIsArray($response);
  17. $this->assertEmpty($response);
  18. }
  19. public function testUpdateStopWords(): void
  20. {
  21. $newStopWords = ['the'];
  22. $promise = $this->index->updateStopWords($newStopWords);
  23. $this->assertIsValidPromise($promise);
  24. $this->index->waitForPendingUpdate($promise['updateId']);
  25. $stopWords = $this->index->getStopWords();
  26. $this->assertIsArray($stopWords);
  27. $this->assertEquals($newStopWords, $stopWords);
  28. }
  29. public function testResetStopWords(): void
  30. {
  31. $promise = $this->index->updateStopWords(['the']);
  32. $this->index->waitForPendingUpdate($promise['updateId']);
  33. $promise = $this->index->resetStopWords();
  34. $this->assertIsValidPromise($promise);
  35. $this->index->waitForPendingUpdate($promise['updateId']);
  36. $topWords = $this->index->getStopWords();
  37. $this->assertIsArray($topWords);
  38. $this->assertEmpty($topWords);
  39. }
  40. }