diff --git a/webapp/tests/Unit/BaseTestCase.php b/webapp/tests/Unit/BaseTestCase.php index abdbc181b3..ba4649cbc6 100644 --- a/webapp/tests/Unit/BaseTestCase.php +++ b/webapp/tests/Unit/BaseTestCase.php @@ -318,4 +318,13 @@ protected function setupShadowMode(bool $shadowMode): void $dj = self::getContainer()->get(DOMJudgeService::class); $config->saveChanges(['shadow_mode'=>$shadowMode], $eventLog, $dj, treatMissingBooleansAsFalse: false); } + + protected function checkStatusAndFollowRedirect(): Crawler + { + static::assertLessThan( + 400, $this->client->getInternalResponse()->getStatusCode(), + $this->client->getInternalResponse()->getContent() + ); + return $this->client->followRedirect(); + } } diff --git a/webapp/tests/Unit/Controller/Jury/ClarificationControllerTest.php b/webapp/tests/Unit/Controller/Jury/ClarificationControllerTest.php index 95b9716a5b..69ba03609a 100644 --- a/webapp/tests/Unit/Controller/Jury/ClarificationControllerTest.php +++ b/webapp/tests/Unit/Controller/Jury/ClarificationControllerTest.php @@ -111,7 +111,7 @@ public function testClarificationRequestComposeForm(): void 'jury_clarification[message]' => 'This is a clarification', ]); - $this->client->followRedirect(); + $this->checkStatusAndFollowRedirect(); self::assertSelectorTextContains('div.col-sm strong', 'All'); self::assertSelectorTextContains('span.clarification-subject', diff --git a/webapp/tests/Unit/Controller/Jury/JuryControllerTestCase.php b/webapp/tests/Unit/Controller/Jury/JuryControllerTestCase.php index c15771108c..459299a695 100644 --- a/webapp/tests/Unit/Controller/Jury/JuryControllerTestCase.php +++ b/webapp/tests/Unit/Controller/Jury/JuryControllerTestCase.php @@ -299,10 +299,8 @@ public function testCheckAddEntityAdmin(array $element, array $expected): void $this->logIn(); $this->verifyPageResponse('GET', static::$baseUrl, 200); if (static::$add !== '') { - $response = $this->helperSubmitFields($element); - static::assertLessThan(400, $this->client->getInternalResponse()->getStatusCode(), - $this->client->getInternalResponse()->getContent()); - $this->client->followRedirect(); + $this->helperSubmitFields($element); + $this->checkStatusAndFollowRedirect(); foreach ($element as $key => $value) { if (!is_array($value) && !in_array($key, static::$overviewSingleNotShown)) { self::assertSelectorExists('body:contains("' . $value . '")'); diff --git a/webapp/tests/Unit/Controller/Jury/TeamControllerTest.php b/webapp/tests/Unit/Controller/Jury/TeamControllerTest.php index 89d30a05fd..fb914e5586 100644 --- a/webapp/tests/Unit/Controller/Jury/TeamControllerTest.php +++ b/webapp/tests/Unit/Controller/Jury/TeamControllerTest.php @@ -105,7 +105,7 @@ public function testAddWithoutUserThenEdit(): void $this->logIn(); $this->verifyPageResponse('GET', static::$baseUrl, 200); $this->helperSubmitFields($teamToAdd); - $viewPage = $this->client->followRedirect()->getUri(); + $viewPage = $this->checkStatusAndFollowRedirect()->getUri(); $editPage = $viewPage . static::$edit; $this->verifyPageResponse('GET', $editPage, 200); $formFields = [ diff --git a/webapp/tests/Unit/Controller/Team/MiscControllerTest.php b/webapp/tests/Unit/Controller/Team/MiscControllerTest.php index 81eb20de21..e76b3c6204 100644 --- a/webapp/tests/Unit/Controller/Team/MiscControllerTest.php +++ b/webapp/tests/Unit/Controller/Team/MiscControllerTest.php @@ -162,7 +162,7 @@ public function testChangeContest(bool $withReferrer): void // $this->client->request('GET', '/team/change-contest/' . $contest->getCid()); // } // -// $this->client->followRedirect(); +// $this->client->checkStatusAndFollowRedirect(); // // // Check that we are still on the scoreboard. // if ($withReferrer) {