@@ -525,6 +525,55 @@ public function testGetCommitWithInvalidHash(): void
525525 }
526526 }
527527
528+ public function testListBranchesPagination (): void
529+ {
530+ $ repositoryName = 'test-list-branches-pages- ' . \uniqid ();
531+ $ this ->vcsAdapter ->createRepository (static ::$ owner , $ repositoryName , false );
532+
533+ try {
534+ $ this ->vcsAdapter ->createFile (static ::$ owner , $ repositoryName , 'README.md ' , '# Test ' );
535+ $ this ->vcsAdapter ->createBranch (static ::$ owner , $ repositoryName , 'branch-a ' , static ::$ defaultBranch );
536+ $ this ->vcsAdapter ->createBranch (static ::$ owner , $ repositoryName , 'branch-b ' , static ::$ defaultBranch );
537+
538+ /** @var GitHub $adapter */
539+ $ adapter = $ this ->vcsAdapter ;
540+
541+ $ page1 = $ adapter ->listBranches (static ::$ owner , $ repositoryName , 1 , 1 );
542+ $ this ->assertSame (['branch-a ' ], $ page1 );
543+
544+ $ page2 = $ adapter ->listBranches (static ::$ owner , $ repositoryName , 1 , 2 );
545+ $ this ->assertSame (['branch-b ' ], $ page2 );
546+
547+ $ all = $ adapter ->listBranches (static ::$ owner , $ repositoryName , 100 , 1 );
548+ $ this ->assertEqualsCanonicalizing ([static ::$ defaultBranch , 'branch-a ' , 'branch-b ' ], $ all );
549+ } finally {
550+ $ this ->vcsAdapter ->deleteRepository (static ::$ owner , $ repositoryName );
551+ }
552+ }
553+
554+ public function testListBranchesEmptyRepository (): void
555+ {
556+ $ repositoryName = 'test-list-branches-empty- ' . \uniqid ();
557+ $ this ->vcsAdapter ->createRepository (static ::$ owner , $ repositoryName , false );
558+
559+ try {
560+ $ branches = $ this ->vcsAdapter ->listBranches (static ::$ owner , $ repositoryName );
561+
562+ $ this ->assertIsArray ($ branches );
563+ $ this ->assertEmpty ($ branches );
564+ } finally {
565+ $ this ->vcsAdapter ->deleteRepository (static ::$ owner , $ repositoryName );
566+ }
567+ }
568+
569+ public function testListBranchesNonExistingRepository (): void
570+ {
571+ $ branches = $ this ->vcsAdapter ->listBranches (static ::$ owner , 'non-existing-repo- ' . \uniqid ());
572+
573+ $ this ->assertIsArray ($ branches );
574+ $ this ->assertEmpty ($ branches );
575+ }
576+
528577 public function testGetLatestCommit (): void
529578 {
530579 $ repositoryName = 'test-get-latest-commit- ' . \uniqid ();
0 commit comments