Skip to content

Commit

Permalink
Merge #613
Browse files Browse the repository at this point in the history
613: Fix "CsvInBatchesWithDelimiter"  test r=norkunas a=aivchen

# Pull Request

## What does this PR do?
- in the old implementation `willReturnCallback()` wasn't called due to `willReturn()` in the end. I removed `willReturn()` and fixed the test.

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: andrew <and.ivchenkov@gmail.com>
  • Loading branch information
meili-bors[bot] and aivchen authored Jan 22, 2024
2 parents 4810abd + 868c495 commit f07267b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions tests/Endpoints/DocumentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ public function testAddDocumentsCsvInBatches(): void

public function testAddDocumentsCsvInBatchesWithDelimiter(): void
{
$matcher = $this->exactly(2);
$documentCsv = 'id;title'.PHP_EOL;
$documentCsv .= '888221515;Young folks'.PHP_EOL;
$documentCsv .= '235115704;Mister Klein'.PHP_EOL;
Expand All @@ -317,22 +316,22 @@ public function testAddDocumentsCsvInBatchesWithDelimiter(): void
->disableOriginalConstructor()
->getMock();

$index->expects($matcher)
$index->expects($this->exactly(2))
->method('addDocumentsCsv')
->willReturnCallback(function (string $param) use ($matcher): void {
->willReturnCallback(function (string $documents, $primaryKey, $delimiter): void {
static $invocation = 0;
// withConsecutive has no replacement https://github.com/sebastianbergmann/phpunit/issues/4026
switch ($matcher->numberOfInvocations()) {
switch (++$invocation) {
case 1:
$this->assertEquals($param, ["id;title\n888221515;Young folks", null, ';']);
static::assertSame(["id;title\n888221515;Young folks", null, ';'], [$documents, $primaryKey, $delimiter]);
break;
case 2:
$this->assertEquals($param, ["id;title\n235115704;Mister Klein", null, ';']);
static::assertSame(["id;title\n235115704;Mister Klein", null, ';'], [$documents, $primaryKey, $delimiter]);
break;
default:
self::fail();
}
})
->willReturn([], []);
});

$index->addDocumentsCsvInBatches($documentCsv, 1, null, ';');
}
Expand Down

0 comments on commit f07267b

Please sign in to comment.