Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- v1.x

jobs:
update_release_draft:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- staging
- main
- feature/**
- v1.x

jobs:
yaml-lint:
Expand Down
18 changes: 16 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,20 @@
"license": "MIT",
"authors": [
{
"name": "Clementine",
"name": "Clémentine Urquizar",
"email": "[email protected]"
},
{
"name": "Bruno Casali",
"email": "[email protected]"
},
{
"name": "Laurent Cazanove",
"email": "[email protected]"
},
{
"name": "Tomas Norkūnas",
"email": "[email protected]"
}
],
"minimum-stability": "stable",
Expand Down Expand Up @@ -58,7 +70,9 @@
"./vendor/bin/php-cs-fixer fix --verbose --config=.php-cs-fixer.dist.php --using-cache=no --diff"
],
"phpstan": "./vendor/bin/phpstan",
"test": ["sh scripts/tests.sh"]
"test": [
"sh scripts/tests.sh"
]
},
"config": {
"allow-plugins": {
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/Delegates/HandlesMultiSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function multiSearch(array $queries = [], ?MultiSearchFederation $federat

$payload = ['queries' => $body];
if (null !== $federation) {
$payload['federation'] = $federation->toArray();
$payload['federation'] = (object) $federation->toArray();
}

return $this->http->post('/multi-search', $payload);
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __toString()
{
$base = 'Meilisearch ApiException: Http Status: '.$this->httpStatus;

if (!\is_null($this->message)) {
if ('' !== $this->message) {
$base .= ' - Message: '.$this->message;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidResponseBodyException.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __toString()
{
$base = 'Meilisearch InvalidResponseBodyException: Http Status: '.$this->httpStatus;

if ($this->message) {
if ('' !== $this->message) {
$base .= ' - Message: '.$this->message;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/TimeOutException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(?string $message = null, ?int $code = null, ?\Throwa
public function __toString()
{
$base = 'Meilisearch TimeOutException: Code: '.$this->code;
if ($this->message) {
if ('' !== $this->message) {
return $base.' - Message: '.$this->message;
} else {
return $base;
Expand Down
26 changes: 26 additions & 0 deletions tests/Endpoints/MultiSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

namespace Tests\Endpoints;

use Meilisearch\Client;
use Meilisearch\Contracts\FederationOptions;
use Meilisearch\Contracts\MultiSearchFederation;
use Meilisearch\Contracts\SearchQuery;
use Meilisearch\Endpoints\Indexes;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Psr18Client;
use Symfony\Component\HttpClient\Response\MockResponse;
use Tests\TestCase;

final class MultiSearchTest extends TestCase
Expand Down Expand Up @@ -159,4 +163,26 @@ public function testMultiSearchWithDistinctAttribute(): void
self::assertCount(1, $response['results'][1]['hits']);
self::assertSame('fantasy', $response['results'][1]['hits'][0]['genre']);
}

public function testMultiSearchFederationCastingToObject(): void
{
$httpClient = new MockHttpClient(static function (string $method, string $url, array $options): MockResponse {
self::assertSame('POST', $method);
self::assertSame('http://meilisearch/multi-search', $url);
self::assertSame('{"queries":[{"indexUid":"first"},{"indexUid":"second"}],"federation":{}}', $options['body']);

return new MockResponse(
json_encode(['results' => []], \JSON_THROW_ON_ERROR),
['response_headers' => ['content-type' => 'application/json']],
);
});

$client = new Client('http://meilisearch', 'apikey', new Psr18Client($httpClient));
$client->multiSearch([
(new SearchQuery())->setIndexUid('first'),
(new SearchQuery())->setIndexUid('second'),
],
new MultiSearchFederation()
);
}
}
Loading