Skip to content

Commit c49241c

Browse files
committed
fix incompatibilities
1 parent 1fc96bf commit c49241c

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

Service/IndexService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public function persist($document): void
425425
$this->bulk('index', $documentArray);
426426
}
427427

428-
public function commit($commitMode = 'flush', array $params = []): array
428+
public function commit($commitMode = 'refresh', array $params = []): array
429429
{
430430
$bulkResponse = [];
431431
if (!empty($this->bulkQueries)) {

Tests/Functional/Command/IndexExportCommandTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ protected function getDataArray()
2525
return [
2626
DummyDocument::class => [
2727
[
28-
'_id' => 'doc1',
28+
'_id' => 1,
2929
'title' => 'Foo Product',
3030
'number' => 5.00,
3131
],
3232
[
33-
'_id' => 'doc2',
33+
'_id' => 2,
3434
'title' => 'Bar Product',
3535
'number' => 8.33,
3636
],
3737
[
38-
'_id' => 'doc3',
38+
'_id' => 3,
3939
'title' => 'Lao Product',
4040
'number' => 1.95,
4141
],
@@ -88,6 +88,9 @@ public function testIndexExport(array $options, array $expectedResults)
8888
);
8989

9090
$results = $this->parseResult(vfsStream::url('tmp/test.json'), count($expectedResults));
91+
usort($results, function ($a, $b){
92+
return (int)$a['_id'] <=> (int)$b['_id'];
93+
});
9194
$this->assertEquals($expectedResults, $results);
9295
}
9396

@@ -97,7 +100,6 @@ public function testIndexExport(array $options, array $expectedResults)
97100
private function transformDataToResult(string $class): array
98101
{
99102
$expectedResults = [];
100-
$index = $this->getIndex($class);
101103

102104
foreach ($this->getDataArray()[$class] as $document) {
103105
$id = $document['_id'];

Tests/Functional/Command/IndexImportCommandTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function testIndexImport(int $bulkSize, int $realSize, string $filename)
6262
]
6363
);
6464

65+
// $index->refresh();
6566
$search = $index->createSearch()->addQuery(new MatchAllQuery())->setSize($realSize);
6667
$results = $index->findDocuments($search);
6768

Tests/Functional/Result/PersistObjectsTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ public function testAddingValuesToPrivateIdsWithoutSetters()
5555

5656
$document = new IndexWithFieldsDataDocument();
5757
$document->title = 'acme';
58-
5958
$index->persist($document);
6059
$index->commit();
6160

61+
$index->refresh();
62+
6263
$document = $index->findOneBy(['private' => 'acme']);
64+
6365
$this->assertNotNull($document->getId());
6466
}
6567
}

Tests/Unit/Result/AbstractResultsIteratorTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ public function testGetDocumentScore()
4747
{
4848
$rawData = [
4949
'hits' => [
50-
'total' => 3,
50+
'total' => [
51+
'value' => 3
52+
],
5153
'hits' => [
5254
[
5355
'_index' => 'test',
@@ -86,7 +88,7 @@ public function testGetDocumentScore()
8688
$expectedScores = [1, 2, null];
8789
$actualScores = [];
8890

89-
$this->assertEquals($rawData['hits']['total'], $results->count());
91+
$this->assertEquals($rawData['hits']['total']['value'], $results->count());
9092
$this->assertEquals($rawData, $results->getRaw());
9193

9294
foreach ($results as $item) {

0 commit comments

Comments
 (0)