Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "CsvInBatchesWithDelimiter" test #613

Merged
merged 1 commit into from
Jan 22, 2024
Merged
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
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