@@ -467,58 +467,17 @@ public function testGetCommit(): void
467467 $ this ->assertSame ('7ae65094d56edafc48596ffbb77950e741e56412 ' , $ commitDetails ['commitHash ' ]);
468468 }
469469
470- public function testListBranchesFetchesAllPages (): void
470+ public function testListBranchesFetchesMultiplePages (): void
471471 {
472- $ firstPage = [];
473- for ($ i = 1 ; $ i <= 100 ; $ i ++) {
474- $ firstPage [] = ['name ' => "branch- {$ i }" ];
475- }
476-
477- $ secondPage = [];
478- for ($ i = 101 ; $ i <= 135 ; $ i ++) {
479- $ secondPage [] = ['name ' => "branch- {$ i }" ];
480- }
481-
482- $ adapter = new class (new Cache (new None ()), [$ firstPage , $ secondPage ]) extends GitHub {
483- /**
484- * @var array<array<mixed>>
485- */
486- public array $ requests = [];
487-
488- /**
489- * @param array<array<mixed>> $responses
490- */
491- public function __construct (Cache $ cache , private array $ responses )
492- {
493- parent ::__construct ($ cache );
494- $ this ->accessToken = 'test-token ' ;
495- }
496-
497- protected function call (string $ method , string $ path = '' , array $ headers = [], array $ params = [], bool $ decode = true )
498- {
499- $ this ->requests [] = [
500- 'method ' => $ method ,
501- 'path ' => $ path ,
502- 'headers ' => $ headers ,
503- 'params ' => $ params ,
504- ];
505-
506- return [
507- 'headers ' => ['status-code ' => 200 ],
508- 'body ' => array_shift ($ this ->responses ) ?? [],
509- ];
510- }
511- };
472+ $ this ->assertInstanceOf (GitHub::class, $ this ->vcsAdapter );
512473
513- $ branches = $ adapter ->listBranches ('appwrite ' , 'appwrite ' );
474+ /** @var GitHub $adapter */
475+ $ adapter = $ this ->vcsAdapter ;
476+ $ branches = $ adapter ->listBranches ('test-kh ' , 'test1 ' , 1 );
514477
515- $ this ->assertCount (135 , $ branches );
516- $ this ->assertSame ('branch-1 ' , $ branches [0 ]);
517- $ this ->assertSame ('branch-135 ' , $ branches [134 ]);
518- $ this ->assertCount (2 , $ adapter ->requests );
519- $ this ->assertSame ('/repos/appwrite/appwrite/branches ' , $ adapter ->requests [0 ]['path ' ]);
520- $ this ->assertSame (['page ' => 1 , 'per_page ' => 100 ], $ adapter ->requests [0 ]['params ' ]);
521- $ this ->assertSame (['page ' => 2 , 'per_page ' => 100 ], $ adapter ->requests [1 ]['params ' ]);
478+ $ this ->assertIsArray ($ branches );
479+ $ this ->assertContains ('main ' , $ branches );
480+ $ this ->assertContains ('test ' , $ branches );
522481 }
523482
524483 public function testGetLatestCommit (): void
0 commit comments