Skip to content

Commit 9d1fde0

Browse files
committed
Improve test coverage
1 parent 6e88252 commit 9d1fde0

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

tests/VCS/Adapter/GitHubTest.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,10 @@ public function testListBranchesPagination(): void
539539
$adapter = $this->vcsAdapter;
540540

541541
$page1 = $adapter->listBranches(static::$owner, $repositoryName, 1, 1);
542-
$this->assertCount(1, $page1);
542+
$this->assertSame(['branch-a'], $page1);
543543

544544
$page2 = $adapter->listBranches(static::$owner, $repositoryName, 1, 2);
545-
$this->assertCount(1, $page2);
546-
547-
$this->assertNotSame($page1[0], $page2[0]);
545+
$this->assertSame(['branch-b'], $page2);
548546

549547
$all = $adapter->listBranches(static::$owner, $repositoryName, 100, 1);
550548
$this->assertContains(static::$defaultBranch, $all);
@@ -555,6 +553,29 @@ public function testListBranchesPagination(): void
555553
}
556554
}
557555

556+
public function testListBranchesEmptyRepository(): void
557+
{
558+
$repositoryName = 'test-list-branches-empty-' . \uniqid();
559+
$this->vcsAdapter->createRepository(static::$owner, $repositoryName, false);
560+
561+
try {
562+
$branches = $this->vcsAdapter->listBranches(static::$owner, $repositoryName);
563+
564+
$this->assertIsArray($branches);
565+
$this->assertEmpty($branches);
566+
} finally {
567+
$this->vcsAdapter->deleteRepository(static::$owner, $repositoryName);
568+
}
569+
}
570+
571+
public function testListBranchesNonExistingRepository(): void
572+
{
573+
$branches = $this->vcsAdapter->listBranches(static::$owner, 'non-existing-repo-' . \uniqid());
574+
575+
$this->assertIsArray($branches);
576+
$this->assertEmpty($branches);
577+
}
578+
558579
public function testGetLatestCommit(): void
559580
{
560581
$repositoryName = 'test-get-latest-commit-' . \uniqid();

0 commit comments

Comments
 (0)