TestCase.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. declare(strict_types=1);
  3. namespace Tests;
  4. use MeiliSearch\Client;
  5. use PHPUnit\Framework\TestCase as BaseTestCase;
  6. abstract class TestCase extends BaseTestCase
  7. {
  8. protected const DOCUMENTS = [
  9. ['id' => 123, 'title' => 'Pride and Prejudice', 'comment' => 'A great book', 'genre' => 'romance'],
  10. ['id' => 456, 'title' => 'Le Petit Prince', 'comment' => 'A french book', 'genre' => 'adventure'],
  11. ['id' => 2, 'title' => 'Le Rouge et le Noir', 'comment' => 'Another french book', 'genre' => 'romance'],
  12. ['id' => 1, 'title' => 'Alice In Wonderland', 'comment' => 'A weird book', 'genre' => 'fantasy'],
  13. ['id' => 1344, 'title' => 'The Hobbit', 'comment' => 'An awesome book', 'genre' => 'romance'],
  14. ['id' => 4, 'title' => 'Harry Potter and the Half-Blood Prince', 'comment' => 'The best book', 'genre' => 'fantasy'],
  15. ['id' => 42, 'title' => 'The Hitchhiker\'s Guide to the Galaxy'],
  16. ];
  17. protected const HOST = 'http://localhost:7700';
  18. protected const DEFAULT_KEY = 'masterKey';
  19. /**
  20. * @var Client
  21. */
  22. protected $client;
  23. protected function setUp(): void
  24. {
  25. parent::setUp();
  26. $this->client = new Client(self::HOST, self::DEFAULT_KEY);
  27. }
  28. protected function tearDown(): void
  29. {
  30. $this->client->deleteAllIndexes();
  31. }
  32. public function assertIsValidPromise(array $promise): void
  33. {
  34. $this->assertIsArray($promise);
  35. $this->assertArrayHasKey('updateId', $promise);
  36. }
  37. }