From 65f1ef2ae435b5f4e962f4107f6a07ada88c80d3 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Thu, 13 Jul 2023 09:13:42 +0200 Subject: [PATCH] Revert "PHPstan fixes" This reverts commit 28a2cd598d83cf49b9b8da79696d245714a1fa2a. --- webapp/src/Entity/Contest.php | 3 +- .../Controller/Jury/ContestControllerTest.php | 4 -- .../Jury/JuryControllerTestCase.php | 40 +------------------ .../Controller/Jury/UserControllerTest.php | 3 -- 4 files changed, 3 insertions(+), 47 deletions(-) diff --git a/webapp/src/Entity/Contest.php b/webapp/src/Entity/Contest.php index 27c035d454..93dd78587a 100644 --- a/webapp/src/Entity/Contest.php +++ b/webapp/src/Entity/Contest.php @@ -1242,7 +1242,7 @@ public function validate(ExecutionContextInterface $context): void ->buildViolation('Unknown problem provided') ->atPath(sprintf('problems[%d].problem', $idx)) ->addViolation(); - // Fail here as the next checks assume the problem to exist. + // Fail here as the next checks assume the problem to exist. return; } $problemId = $existingProblem->getProbid(); @@ -1252,6 +1252,7 @@ public function validate(ExecutionContextInterface $context): void ->atPath(sprintf('problems[%d].problem', $idx)) ->addViolation(); } + // Check if the problem shortname is unique. $otherShortNames = $this->problems ->filter(fn(ContestProblem $otherProblem) => $otherProblem !== $problem) diff --git a/webapp/tests/Unit/Controller/Jury/ContestControllerTest.php b/webapp/tests/Unit/Controller/Jury/ContestControllerTest.php index d716dd42ce..78bbc1aeb8 100644 --- a/webapp/tests/Unit/Controller/Jury/ContestControllerTest.php +++ b/webapp/tests/Unit/Controller/Jury/ContestControllerTest.php @@ -207,10 +207,6 @@ class ContestControllerTest extends JuryControllerTestCase 'allowJudge' => '1', 'color' => '#000000', 'lazyEvalResults' => '0']]]]; - - /** - * @param array>> $addEntitiesFailure - */ protected static array $addEntitiesFailure = ['Contest should not have multiple timezones.' => [['shortname' => 'tz', 'name' => 'Timezones', 'activatetimeString' => '1990-07-17 16:00:00 Africa/Douala', diff --git a/webapp/tests/Unit/Controller/Jury/JuryControllerTestCase.php b/webapp/tests/Unit/Controller/Jury/JuryControllerTestCase.php index c9e0aa2247..57f8007ba5 100644 --- a/webapp/tests/Unit/Controller/Jury/JuryControllerTestCase.php +++ b/webapp/tests/Unit/Controller/Jury/JuryControllerTestCase.php @@ -48,28 +48,13 @@ abstract class JuryControllerTestCase extends BaseTestCase protected static array $addEntities = []; protected static array $addEntitiesCount = []; protected static array $addEntitiesShown = []; - /** - * @var array> $addEntitiesFailure - */ protected static array $addEntitiesFailure = []; - /** - * @var array> $addEntitiesNonLocal - */ protected static array $addEntitiesNonLocal = []; - /** - * @var array>> $addEntitiesFailureNonLocal - */ protected static array $addEntitiesFailureNonLocal = []; protected static ?string $defaultEditEntityName = null; protected static array $specialFieldOnlyUpdate = []; protected static array $editEntitiesSkipFields = []; - /** - * @var array $overviewSingleNotShown - */ protected static array $overviewSingleNotShown = []; - /** - * @var array $overviewGeneralNotShown - */ protected static array $overviewGeneralNotShown = []; protected function setUp(): void @@ -307,8 +292,6 @@ protected function helperSubmitFields(array $element): Crawler { /** * Test that admin can add a new entity for this controller. - * @param array> $element - * @param array $expected * @dataProvider provideAddCorrectEntities */ public function testCheckAddEntityAdmin(array $element, array $expected): void @@ -349,7 +332,6 @@ public function testCheckAddEntityAdmin(array $element, array $expected): void /** * Test failures when the admin provides wrong data. - * @param array> $element * @dataProvider provideAddFailureEntities */ public function testCheckAddEntityAdminFailure(array $element, string $message): void @@ -369,8 +351,6 @@ public function testCheckAddEntityAdminFailure(array $element, string $message): /** * Test that admin can add edit an entity for this controller. * - * @param array $formDataKeys - * @param array $formDataValues * @dataProvider provideEditCorrectEntities */ public function testCheckEditEntityAdminCorrect(array $formDataKeys, array $formDataValues): void @@ -415,9 +395,6 @@ public function testCheckEditEntityAdminCorrect(array $formDataKeys, array $form $this->verifyPageResponse('GET', $singlePageLink, 200); foreach ($formDataValues as $id => $element) { if (in_array($formDataKeys[$id], static::$addEntitiesShown)) { - /** - * @var string $element - */ self::assertSelectorExists('body:contains("' . $element . '")'); } } @@ -430,8 +407,6 @@ public function testCheckEditEntityAdminCorrect(array $formDataKeys, array $form /** * Test that admin can edit an entity for this controller but receives an error when providing wrong data. * - * @param array $formDataKeys - * @param array $formDataValues * @dataProvider provideEditFailureEntities */ public function testCheckEditEntityAdminFailure(array $formDataKeys, array $formDataValues, string $message): void @@ -497,7 +472,7 @@ public function provideAddFailureEntities(): Generator $entities = array_merge($entities, static::$addEntitiesFailureNonLocal); } foreach ($entities as $message => $elementList) { - foreach($elementList as $element) { + foreach ($elementList as $element) { [$entity, $expected] = $this->helperProvideMergeAddEntity($element); [$entity, $dropped] = $this->helperProvideTranslateAddEntity($entity, $expected); yield [$entity, $message]; @@ -505,10 +480,6 @@ public function provideAddFailureEntities(): Generator } } - /** - * @param array> $overWriteValues - * @return array>> - */ protected function helperProvideMergeAddEntity(array $overWriteValues): array { $combinedValues = []; @@ -522,20 +493,11 @@ protected function helperProvideMergeAddEntity(array $overWriteValues): array return [$combinedValues, $overWriteValues]; } - /** - * @param array> $entity - * @param array> $expected - * @return array>> - */ protected function helperProvideTranslateAddEntity(array $entity, array $expected): array { return [$entity, $expected]; } - /** - * @param array $element - * @return array> - */ public function helperProvideMergeEditEntity(array $element): array { $formdataKeys = []; diff --git a/webapp/tests/Unit/Controller/Jury/UserControllerTest.php b/webapp/tests/Unit/Controller/Jury/UserControllerTest.php index 928f907382..d041be8d96 100644 --- a/webapp/tests/Unit/Controller/Jury/UserControllerTest.php +++ b/webapp/tests/Unit/Controller/Jury/UserControllerTest.php @@ -78,9 +78,6 @@ class UserControllerTest extends JuryControllerTestCase 'user_roles' => ['7' => true]], ['username' => 'singlerole-8', 'name' => 'Single Role-8', 'user_roles' => ['8' => true]]]; - /** - * @param array $addEntitiesFailure - */ protected static array $addEntitiesFailure = ['Only alphanumeric characters and _-@. are allowed' => [['username' => '|user', 'name' => 'StartWith'], ['username' => 'user|', 'name' => 'EndWith'], ['username' => 'us er', 'name' => 'SpaceUsage'],