13
13
use PHPUnit \Framework \Attributes \DataProvider ;
14
14
use PHPUnit \Framework \TestCase ;
15
15
use Neo4j \QueryAPI \Transaction ;
16
+ use Psr \Http \Client \RequestExceptionInterface ;
16
17
17
18
class Neo4jQueryAPIIntegrationTest extends TestCase
18
19
{
@@ -426,8 +427,13 @@ public function testWithString(): void
426
427
$ this ->assertCount (1 , $ results ->getBookmarks ());
427
428
}
428
429
430
+ /**
431
+ * @throws Neo4jException
432
+ * @throws RequestExceptionInterface
433
+ */
429
434
public function testWithArray (): void
430
435
{
436
+ // Expected result
431
437
$ expected = new ResultSet (
432
438
[
433
439
new ResultRow (['n.name ' => 'bob1 ' ]),
@@ -442,16 +448,41 @@ public function testWithArray(): void
442
448
new Bookmarks ([])
443
449
);
444
450
451
+ // Actual results from API
445
452
$ results = $ this ->api ->run (
446
453
'MATCH (n:Person) WHERE n.name IN $names RETURN n.name ' ,
447
454
['names ' => ['bob1 ' , 'alicy ' ]]
448
455
);
449
456
457
+ // Assert counters
450
458
$ 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
452
481
$ this ->assertCount (1 , $ results ->getBookmarks ());
453
482
}
454
483
484
+
485
+
455
486
public function testWithDate (): void
456
487
{
457
488
$ expected = new ResultSet (
0 commit comments