Skip to content

Commit 0e91aa0

Browse files
author
Your Name
committed
updated githubtests file with the same patter as giteatest in webhook and removed the testgetevent
1 parent 99041df commit 0e91aa0

3 files changed

Lines changed: 30 additions & 30 deletions

File tree

tests/VCS/Adapter/GitHubTest.php

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public function setUp(): void
2626
$this->vcsAdapter->initializeVariables(installationId: $installationId, privateKey: $privateKey, appId: $appId, accessToken: '', refreshToken: '');
2727
}
2828

29-
public function testGetEvent(): void
29+
public function testGetEventPush(): void
3030
{
31-
$payload_push = '{
31+
$payload = '{
3232
"created": false,
3333
"ref": "refs/heads/main",
3434
"before": "1234",
@@ -91,7 +91,19 @@ public function testGetEvent(): void
9191
}
9292
}';
9393

94-
$payload_pull_request = '{
94+
$result = $this->vcsAdapter->getEvent('push', $payload);
95+
96+
$this->assertSame('main', $result['branch']);
97+
$this->assertSame('603754812', $result['repositoryId']);
98+
$this->assertCount(3, $result['affectedFiles']);
99+
$this->assertSame('src/lib.js', $result['affectedFiles'][0]);
100+
$this->assertSame('README.md', $result['affectedFiles'][1]);
101+
$this->assertSame('src/main.js', $result['affectedFiles'][2]);
102+
}
103+
104+
public function testGetEventPullRequest(): void
105+
{
106+
$payload = '{
95107
"action": "opened",
96108
"number": 1,
97109
"pull_request": {
@@ -133,32 +145,28 @@ public function testGetEvent(): void
133145
}
134146
}';
135147

136-
$payload_uninstall = '{
148+
$result = $this->vcsAdapter->getEvent('pull_request', $payload);
149+
150+
$this->assertSame('opened', $result['action']);
151+
$this->assertSame(1, $result['pullRequestNumber']);
152+
}
153+
154+
public function testGetEventInstallation(): void
155+
{
156+
$payload = '{
137157
"action": "deleted",
138158
"installation": {
139159
"id": 1234,
140160
"account": {
141161
"login": "vermakhushboo"
142162
}
143163
}
144-
}
145-
';
146-
147-
$pushResult = $this->vcsAdapter->getEvent('push', $payload_push);
148-
$this->assertSame('main', $pushResult['branch']);
149-
$this->assertSame('603754812', $pushResult['repositoryId']);
150-
$this->assertCount(3, $pushResult['affectedFiles']);
151-
$this->assertSame('src/lib.js', $pushResult['affectedFiles'][0]);
152-
$this->assertSame('README.md', $pushResult['affectedFiles'][1]);
153-
$this->assertSame('src/main.js', $pushResult['affectedFiles'][2]);
154-
155-
$pullRequestResult = $this->vcsAdapter->getEvent('pull_request', $payload_pull_request);
156-
$this->assertSame('opened', $pullRequestResult['action']);
157-
$this->assertSame(1, $pullRequestResult['pullRequestNumber']);
158-
159-
$uninstallResult = $this->vcsAdapter->getEvent('installation', $payload_uninstall);
160-
$this->assertSame('deleted', $uninstallResult['action']);
161-
$this->assertSame('1234', $uninstallResult['installationId']);
164+
}';
165+
166+
$result = $this->vcsAdapter->getEvent('installation', $payload);
167+
168+
$this->assertSame('deleted', $result['action']);
169+
$this->assertSame('1234', $result['installationId']);
162170
}
163171

164172
public function testGetComment(): void

tests/VCS/Adapter/GiteaTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -641,12 +641,6 @@ public function testGetLatestCommitWithInvalidBranch(): void
641641
}
642642
}
643643

644-
public function testGetEvent(): void
645-
{
646-
// Base class requires this method - implemented via specific event tests below
647-
$this->assertTrue(true);
648-
}
649-
650644
public function testGetEventPush(): void
651645
{
652646
$payload = json_encode([

tests/VCS/Base.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ abstract public function testGenerateCloneCommand(): void;
2525

2626
abstract public function testGenerateCloneCommandWithCommitHash(): void;
2727

28-
abstract public function testGetEvent(): void;
29-
3028
abstract public function testGetRepositoryName(): void;
3129

3230
abstract public function testGetComment(): void;

0 commit comments

Comments
 (0)