Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions tests/VCS/Adapter/GitHubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,16 @@ public function testgetEvent(): void
';

$pushResult = $this->vcsAdapter->getEvent('push', $payload_push);
$this->assertEquals('main', $pushResult['branch']);
$this->assertEquals('603754812', $pushResult['repositoryId']);
$this->assertSame('main', $pushResult['branch']);
$this->assertSame('603754812', $pushResult['repositoryId']);

$pullRequestResult = $this->vcsAdapter->getEvent('pull_request', $payload_pull_request);
$this->assertEquals('opened', $pullRequestResult['action']);
$this->assertEquals(1, $pullRequestResult['pullRequestNumber']);
$this->assertSame('opened', $pullRequestResult['action']);
$this->assertSame(1, $pullRequestResult['pullRequestNumber']);

$uninstallResult = $this->vcsAdapter->getEvent('installation', $payload_uninstall);
$this->assertEquals('deleted', $uninstallResult['action']);
$this->assertEquals(1234, $uninstallResult['installationId']);
$this->assertSame('deleted', $uninstallResult['action']);
$this->assertSame('1234', $uninstallResult['installationId']);
}

public function testGetComment(): void
Expand All @@ -141,7 +141,7 @@ public function testGetComment(): void
public function testGetRepositoryName(): void
{
$repositoryName = $this->vcsAdapter->getRepositoryName('432284323');
$this->assertEquals('basic-js-crud', $repositoryName);
$this->assertSame('basic-js-crud', $repositoryName);
}

public function testGetRepositoryTree(): void
Expand Down Expand Up @@ -171,14 +171,14 @@ public function testGetRepositoryTree(): void
$tree = $this->vcsAdapter->getRepositoryTree($owner, $repositoryName, $branch, true);
$this->assertIsArray($tree);
$this->assertNotEmpty($tree);
$this->assertEquals('src/folder/README.md', $tree[2]);
$this->assertSame('src/folder/README.md', $tree[2]);

// test for recursive false
$repositoryName = 'test4';
$tree = $this->vcsAdapter->getRepositoryTree($owner, $repositoryName, $branch);
$this->assertIsArray($tree);
$this->assertNotEmpty($tree);
$this->assertEquals(1, count($tree));
$this->assertSame(1, count($tree));
}

public function testGetRepositoryContent(): void
Expand All @@ -188,21 +188,21 @@ public function testGetRepositoryContent(): void

// Basic usage
$response = $this->vcsAdapter->getRepositoryContent($owner, $repositoryName, 'README.md');
$this->assertEquals('# test1', $response['content']);
$this->assertSame('# test1', $response['content']);

$sha = \hash('sha1', "blob " . $response['size'] . "\0" . $response['content']);
$this->assertEquals(7, $response['size']);
$this->assertEquals($sha, $response['sha']);
$this->assertSame(7, $response['size']);
$this->assertSame($sha, $response['sha']);

$response = $this->vcsAdapter->getRepositoryContent($owner, $repositoryName, 'src/index.md');
$this->assertEquals("Hello\n", $response['content']);
$this->assertSame("Hello\n", $response['content']);

// Branches
$response = $this->vcsAdapter->getRepositoryContent($owner, $repositoryName, 'README.md', 'main');
$this->assertEquals('# test1', $response['content']);
$this->assertSame('# test1', $response['content']);

$response = $this->vcsAdapter->getRepositoryContent($owner, $repositoryName, 'README.md', 'test');
$this->assertEquals("# test1 from test branch\n", $response['content']);
$this->assertSame("# test1 from test branch\n", $response['content']);

$threw = false;
try {
Expand Down Expand Up @@ -285,9 +285,9 @@ public function testGetPullRequest(): void

$this->assertIsArray($result);
$this->assertNotEmpty($result);
$this->assertEquals($pullRequestNumber, $result['number']);
$this->assertEquals($owner, $result['base']['user']['login']);
$this->assertEquals($repositoryName, $result['base']['repo']['name']);
$this->assertSame($pullRequestNumber, $result['number']);
$this->assertSame($owner, $result['base']['user']['login']);
$this->assertSame($repositoryName, $result['base']['repo']['name']);
}

public function testGenerateCloneCommand(): void
Expand All @@ -299,7 +299,7 @@ public function testGenerateCloneCommand(): void
$output = '';
$resultCode = null;
\exec($gitCloneCommand, $output, $resultCode);
$this->assertEquals(0, $resultCode);
$this->assertSame(0, $resultCode);

$this->assertFileExists('/tmp/clone-branch/README.md');
}
Expand All @@ -313,7 +313,7 @@ public function testGenerateCloneCommandWithCommitHash(): void
$output = '';
$resultCode = null;
\exec($gitCloneCommand, $output, $resultCode);
$this->assertEquals(0, $resultCode);
$this->assertSame(0, $resultCode);

$this->assertFileExists('/tmp/clone-commit/README.md');
}
Expand All @@ -327,7 +327,7 @@ public function testGenerateCloneCommandWithTag(): void
$output = '';
$resultCode = null;
\exec($gitCloneCommand, $output, $resultCode);
$this->assertEquals(0, $resultCode);
$this->assertSame(0, $resultCode);

$this->assertFileExists('/tmp/clone-tag/README.md');

Expand All @@ -338,7 +338,7 @@ public function testGenerateCloneCommandWithTag(): void
$output = '';
$resultCode = null;
\exec($gitCloneCommand, $output, $resultCode);
$this->assertEquals(0, $resultCode);
$this->assertSame(0, $resultCode);

$this->assertFileExists('/tmp/clone-tag2/README.md');

Expand All @@ -349,7 +349,7 @@ public function testGenerateCloneCommandWithTag(): void
$output = '';
$resultCode = null;
\exec($gitCloneCommand, $output, $resultCode);
$this->assertEquals(0, $resultCode);
$this->assertSame(0, $resultCode);

$this->assertFileExists('/tmp/clone-tag3/README.md');

Expand All @@ -376,19 +376,19 @@ public function testGetCommit(): void
{
$commitDetails = $this->vcsAdapter->getCommit('test-kh', 'test1', '7ae65094d56edafc48596ffbb77950e741e56412');
$this->assertIsArray($commitDetails);
$this->assertEquals('https://avatars.githubusercontent.com/u/43381712?v=4', $commitDetails['commitAuthorAvatar']);
$this->assertEquals('https://github.com/vermakhushboo', $commitDetails['commitAuthorUrl']);
$this->assertEquals('Khushboo Verma', $commitDetails['commitAuthor']);
$this->assertEquals('Initial commit', $commitDetails['commitMessage']);
$this->assertEquals('https://github.com/test-kh/test1/commit/7ae65094d56edafc48596ffbb77950e741e56412', $commitDetails['commitUrl']);
$this->assertEquals('7ae65094d56edafc48596ffbb77950e741e56412', $commitDetails['commitHash']);
$this->assertSame('https://avatars.githubusercontent.com/u/43381712?v=4', $commitDetails['commitAuthorAvatar']);
$this->assertSame('https://github.com/vermakhushboo', $commitDetails['commitAuthorUrl']);
$this->assertSame('Khushboo Verma', $commitDetails['commitAuthor']);
$this->assertSame('Initial commit', $commitDetails['commitMessage']);
$this->assertSame('https://github.com/test-kh/test1/commit/7ae65094d56edafc48596ffbb77950e741e56412', $commitDetails['commitUrl']);
$this->assertSame('7ae65094d56edafc48596ffbb77950e741e56412', $commitDetails['commitHash']);
}

public function testGetLatestCommit(): void
{
$commitDetails = $this->vcsAdapter->getLatestCommit('test-kh', 'test1', 'test');
$this->assertEquals('Khushboo Verma', $commitDetails['commitAuthor']);
$this->assertEquals('https://avatars.githubusercontent.com/u/43381712?v=4', $commitDetails['commitAuthorAvatar']);
$this->assertEquals('https://github.com/vermakhushboo', $commitDetails['commitAuthorUrl']);
$this->assertSame('Khushboo Verma', $commitDetails['commitAuthor']);
$this->assertSame('https://avatars.githubusercontent.com/u/43381712?v=4', $commitDetails['commitAuthorAvatar']);
$this->assertSame('https://github.com/vermakhushboo', $commitDetails['commitAuthorUrl']);
}
}
8 changes: 4 additions & 4 deletions tests/VCS/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testGetOwnerName(): void
{
$installationId = System::getEnv('INSTALLATION_ID') ?? '';
$owner = $this->vcsAdapter->getOwnerName($installationId);
$this->assertEquals('test-kh', $owner);
$this->assertSame('test-kh', $owner);
}

public function testSearchRepositories(): void
Expand Down Expand Up @@ -119,14 +119,14 @@ public function testListRepositoryContents(): void
$this->assertNotNull($directoryContent);
$this->assertNotEmpty($directoryContent['name']);
$this->assertIsNumeric($directoryContent['size']);
$this->assertEquals(0, $directoryContent['size']);
$this->assertSame(0, $directoryContent['size']);
}

public function testCreateRepository(): void
{
$repository = $this->vcsAdapter->createRepository('test-kh', 'new-repo', true);
$this->assertIsArray($repository);
$this->assertEquals('test-kh/new-repo', $repository['full_name']);
$this->assertSame('test-kh/new-repo', $repository['full_name']);
}

/**
Expand All @@ -135,7 +135,7 @@ public function testCreateRepository(): void
public function testDeleteRepository(): void
{
$result = $this->vcsAdapter->deleteRepository('test-kh', 'new-repo');
$this->assertEquals(true, $result);
$this->assertSame(true, $result);
$this->expectException(Exception::class);
$result = $this->vcsAdapter->deleteRepository('test-kh', 'new-repo-2');
}
Expand Down