Skip to content

Commit f11e4d4

Browse files
committed
winp
1 parent 9da379d commit f11e4d4

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

tests/Integration/Neo4jQueryAPIIntegrationTest.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use PHPUnit\Framework\Attributes\DataProvider;
1414
use PHPUnit\Framework\TestCase;
1515
use Neo4j\QueryAPI\Transaction;
16+
use Psr\Http\Client\RequestExceptionInterface;
1617

1718
class Neo4jQueryAPIIntegrationTest extends TestCase
1819
{
@@ -426,8 +427,13 @@ public function testWithString(): void
426427
$this->assertCount(1, $results->getBookmarks());
427428
}
428429

430+
/**
431+
* @throws Neo4jException
432+
* @throws RequestExceptionInterface
433+
*/
429434
public function testWithArray(): void
430435
{
436+
// Expected result
431437
$expected = new ResultSet(
432438
[
433439
new ResultRow(['n.name' => 'bob1']),
@@ -442,16 +448,41 @@ public function testWithArray(): void
442448
new Bookmarks([])
443449
);
444450

451+
// Actual results from API
445452
$results = $this->api->run(
446453
'MATCH (n:Person) WHERE n.name IN $names RETURN n.name',
447454
['names' => ['bob1', 'alicy']]
448455
);
449456

457+
// Assert counters
450458
$this->assertEquals($expected->getQueryCounters(), $results->getQueryCounters());
451-
$this->assertEquals(iterator_to_array($expected), iterator_to_array($results));
459+
460+
// Compare ResultRows
461+
$this->assertCount(count($expected), $results);
462+
463+
$expectedRows = iterator_to_array($expected);
464+
$actualRows = iterator_to_array($results);
465+
466+
$this->assertCount(count($expectedRows), $actualRows);
467+
468+
// Compare each row
469+
foreach ($expectedRows as $expectedRow) {
470+
$found = false;
471+
foreach ($actualRows as $actualRow) {
472+
if ($expectedRow == $actualRow) {
473+
$found = true;
474+
break;
475+
}
476+
}
477+
$this->assertTrue($found, "Expected row not found: " . json_encode($expectedRow));
478+
}
479+
480+
// Check bookmarks count
452481
$this->assertCount(1, $results->getBookmarks());
453482
}
454483

484+
485+
455486
public function testWithDate(): void
456487
{
457488
$expected = new ResultSet(

0 commit comments

Comments
 (0)