@@ -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
0 commit comments