Skip to content

Commit a5d01e6

Browse files
committed
Add missing assert respone code to tests
1 parent 3326c00 commit a5d01e6

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

tests/TestCase/Controller/GithubControllerTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function testCreateIssue(): void
7979

8080
// Case 2. Test form with valid reportId
8181
$this->get('github/create_issue/5');
82-
$this->assertResponseSuccess();
82+
$this->assertResponseCode(200);
8383
$this->assertResponseContains('Lorem ipsum dolor sit amet'); // Description
8484

8585
$issueResponse = file_get_contents(TESTS . 'Fixture' . DS . 'issue_response.json');
@@ -98,7 +98,7 @@ public function testCreateIssue(): void
9898
'labels' => 'test-pma',
9999
]
100100
);
101-
$this->assertResponseSuccess();
101+
$this->assertResponseCode(200);
102102
$this->cleanupMockResponses();
103103

104104
$this->enableRetainFlashMessages();
@@ -125,6 +125,7 @@ public function testCreateIssue(): void
125125
'labels' => 'test-pma',
126126
]
127127
);
128+
$this->assertResponseCode(302);
128129

129130
$report = $this->Reports->get(5);
130131
$this->assertEquals(1347, $report->sourceforge_bug_id);
@@ -140,10 +141,12 @@ public function testLinkIssue(): void
140141

141142
// Case 1.1 Test with an invalid reportId
142143
$this->get('github/link_issue/123?ticket_id=1');
144+
$this->assertResponseCode(404);
143145
$this->assertResponseContains('The report does not exist.');
144146

145147
// Case 1.2 Test with an invalid ticketId
146148
$this->get('github/link_issue/5?ticket_id=');
149+
$this->assertResponseCode(404);
147150
$this->assertResponseContains('Invalid Ticket ID');
148151

149152
$issueResponse = file_get_contents(TESTS . 'Fixture' . DS . 'issue_response.json');
@@ -164,6 +167,7 @@ public function testLinkIssue(): void
164167
$this->get(
165168
'github/link_issue/5?ticket_id=9999999'
166169
);
170+
$this->assertResponseCode(302);
167171

168172
$this->enableRetainFlashMessages();
169173
$report = $this->Reports->get(5);
@@ -188,6 +192,7 @@ public function testLinkIssue(): void
188192
$this->get(
189193
'github/link_issue/5?ticket_id=1387'
190194
);
195+
$this->assertResponseCode(302);
191196

192197
$report = $this->Reports->get(5);
193198
$this->assertEquals(1387, $report->sourceforge_bug_id);
@@ -206,6 +211,7 @@ public function testLinkIssue(): void
206211
$this->get(
207212
'github/link_issue/5?ticket_id=1387'
208213
);
214+
$this->assertResponseCode(302);
209215

210216
$report = $this->Reports->get(5);
211217
$this->assertEquals(1387, $report->sourceforge_bug_id);
@@ -222,10 +228,12 @@ public function testUnlinkIssue(): void
222228

223229
// Case 1.1 Test with an invalid reportId
224230
$this->get('github/unlink_issue/123');
231+
$this->assertResponseCode(404);
225232
$this->assertResponseContains('The report does not exist.');
226233

227234
// Case 1.2 Test unlinked with an already unlinked issue
228235
$this->get('github/unlink_issue/5');
236+
$this->assertResponseCode(404);
229237
$this->assertResponseContains('Invalid Ticket ID');
230238

231239
$commentResponse = file_get_contents(TESTS . 'Fixture' . DS . 'comment_response.json');
@@ -244,6 +252,7 @@ public function testUnlinkIssue(): void
244252
$this->get(
245253
'github/unlink_issue/5'
246254
);
255+
$this->assertResponseCode(302);
247256

248257
$this->enableRetainFlashMessages();
249258
$report = $this->Reports->get(5);
@@ -263,6 +272,7 @@ public function testUnlinkIssue(): void
263272
$this->get(
264273
'github/unlink_issue/5'
265274
);
275+
$this->assertResponseCode(302);
266276

267277
$report = $this->Reports->get(5);
268278
$this->assertEquals(null, $report->sourceforge_bug_id);
@@ -281,6 +291,7 @@ public function testSyncIssueStatus(): void
281291
Configure::write('CronDispatcher', false);
282292
$this->enableRetainFlashMessages();
283293
$this->get('github/sync_issue_status');
294+
$this->assertResponseCode(302);
284295
$this->assertRedirect('/');
285296

286297
$issueResponse = file_get_contents(TESTS . 'Fixture' . DS . 'issue_response.json');
@@ -306,6 +317,7 @@ public function testSyncIssueStatus(): void
306317
// Test via cli (i.e. the CronDispatcher setting should be defined)
307318
Configure::write('CronDispatcher', true);
308319
$this->get('github/sync_issue_status');
320+
$this->assertResponseCode(200);
309321

310322
// 401
311323
$report = $this->Reports->get(1);

0 commit comments

Comments
 (0)