@@ -471,11 +471,17 @@ public function testListBranches(): void
471471 try {
472472 $ this ->vcsAdapter ->createFile (static ::$ owner , $ repositoryName , 'README.md ' , '# Test ' );
473473
474- $ branches = $ this ->vcsAdapter ->listBranches (static ::$ owner , $ repositoryName );
474+ /** @var GitHub $adapter */
475+ $ adapter = $ this ->vcsAdapter ;
476+ $ branches = $ adapter ->listBranches (static ::$ owner , $ repositoryName );
475477
476478 $ this ->assertIsArray ($ branches );
477- $ this ->assertNotEmpty ($ branches );
478- $ this ->assertContains (static ::$ defaultBranch , $ branches );
479+ $ this ->assertArrayHasKey ('items ' , $ branches );
480+ $ this ->assertArrayHasKey ('hasNext ' , $ branches );
481+ $ this ->assertNotEmpty ($ branches ['items ' ]);
482+ $ this ->assertFalse ($ branches ['hasNext ' ]);
483+ $ this ->assertNull ($ branches ['nextCursor ' ]);
484+ $ this ->assertContains (static ::$ defaultBranch , $ branches ['items ' ]);
479485 } finally {
480486 $ this ->vcsAdapter ->deleteRepository (static ::$ owner , $ repositoryName );
481487 }
@@ -539,13 +545,37 @@ public function testListBranchesPagination(): void
539545 $ adapter = $ this ->vcsAdapter ;
540546
541547 $ page1 = $ adapter ->listBranches (static ::$ owner , $ repositoryName , 1 , 1 );
542- $ this ->assertSame (['branch-a ' ], $ page1 );
548+ $ this ->assertSame (['branch-a ' ], $ page1 ['items ' ]);
549+ $ this ->assertTrue ($ page1 ['hasNext ' ]);
550+ $ this ->assertNotEmpty ($ page1 ['nextCursor ' ]);
543551
544552 $ page2 = $ adapter ->listBranches (static ::$ owner , $ repositoryName , 1 , 2 );
545- $ this ->assertSame (['branch-b ' ], $ page2 );
553+ $ this ->assertSame (['branch-b ' ], $ page2 ['items ' ]);
554+ $ this ->assertTrue ($ page2 ['hasNext ' ]);
555+ $ this ->assertNotEmpty ($ page2 ['nextCursor ' ]);
556+
557+ $ cursorPage2 = $ adapter ->listBranches (static ::$ owner , $ repositoryName , 1 , $ page1 ['nextCursor ' ]);
558+ $ this ->assertSame ($ page2 , $ cursorPage2 );
559+
560+ $ page3 = $ adapter ->listBranches (static ::$ owner , $ repositoryName , 1 , 3 );
561+ $ this ->assertSame ([static ::$ defaultBranch ], $ page3 ['items ' ]);
562+ $ this ->assertFalse ($ page3 ['hasNext ' ]);
563+ $ this ->assertNull ($ page3 ['nextCursor ' ]);
546564
547565 $ all = $ adapter ->listBranches (static ::$ owner , $ repositoryName , 100 , 1 );
548- $ this ->assertEqualsCanonicalizing ([static ::$ defaultBranch , 'branch-a ' , 'branch-b ' ], $ all );
566+ $ this ->assertEqualsCanonicalizing ([static ::$ defaultBranch , 'branch-a ' , 'branch-b ' ], $ all ['items ' ]);
567+ $ this ->assertFalse ($ all ['hasNext ' ]);
568+ $ this ->assertNull ($ all ['nextCursor ' ]);
569+
570+ $ searchPage1 = $ adapter ->listBranches (static ::$ owner , $ repositoryName , 1 , 1 , 'branch ' );
571+ $ this ->assertSame (['branch-a ' ], $ searchPage1 ['items ' ]);
572+ $ this ->assertTrue ($ searchPage1 ['hasNext ' ]);
573+ $ this ->assertNotEmpty ($ searchPage1 ['nextCursor ' ]);
574+
575+ $ searchPage2 = $ adapter ->listBranches (static ::$ owner , $ repositoryName , 1 , $ searchPage1 ['nextCursor ' ], 'branch ' );
576+ $ this ->assertSame (['branch-b ' ], $ searchPage2 ['items ' ]);
577+ $ this ->assertFalse ($ searchPage2 ['hasNext ' ]);
578+ $ this ->assertNull ($ searchPage2 ['nextCursor ' ]);
549579 } finally {
550580 $ this ->vcsAdapter ->deleteRepository (static ::$ owner , $ repositoryName );
551581 }
@@ -557,21 +587,29 @@ public function testListBranchesEmptyRepository(): void
557587 $ this ->vcsAdapter ->createRepository (static ::$ owner , $ repositoryName , false );
558588
559589 try {
560- $ branches = $ this ->vcsAdapter ->listBranches (static ::$ owner , $ repositoryName );
590+ /** @var GitHub $adapter */
591+ $ adapter = $ this ->vcsAdapter ;
592+ $ branches = $ adapter ->listBranches (static ::$ owner , $ repositoryName );
561593
562594 $ this ->assertIsArray ($ branches );
563- $ this ->assertEmpty ($ branches );
595+ $ this ->assertSame ([], $ branches ['items ' ]);
596+ $ this ->assertFalse ($ branches ['hasNext ' ]);
597+ $ this ->assertNull ($ branches ['nextCursor ' ]);
564598 } finally {
565599 $ this ->vcsAdapter ->deleteRepository (static ::$ owner , $ repositoryName );
566600 }
567601 }
568602
569603 public function testListBranchesNonExistingRepository (): void
570604 {
571- $ branches = $ this ->vcsAdapter ->listBranches (static ::$ owner , 'non-existing-repo- ' . \uniqid ());
605+ /** @var GitHub $adapter */
606+ $ adapter = $ this ->vcsAdapter ;
607+ $ branches = $ adapter ->listBranches (static ::$ owner , 'non-existing-repo- ' . \uniqid ());
572608
573609 $ this ->assertIsArray ($ branches );
574- $ this ->assertEmpty ($ branches );
610+ $ this ->assertSame ([], $ branches ['items ' ]);
611+ $ this ->assertFalse ($ branches ['hasNext ' ]);
612+ $ this ->assertNull ($ branches ['nextCursor ' ]);
575613 }
576614
577615 public function testGetLatestCommit (): void
0 commit comments