From 868c495fa76eb017962e9c48e8627e8749a03ed6 Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 22 Jan 2024 01:01:35 +0300 Subject: [PATCH] Fix test --- tests/Endpoints/DocumentsTest.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/Endpoints/DocumentsTest.php b/tests/Endpoints/DocumentsTest.php index e8948098..651ebc92 100644 --- a/tests/Endpoints/DocumentsTest.php +++ b/tests/Endpoints/DocumentsTest.php @@ -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; @@ -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, ';'); }