Skip to content

Commit

Permalink
Revert "PHPstan fixes"
Browse files Browse the repository at this point in the history
This reverts commit 28a2cd5.
  • Loading branch information
vmcj committed Aug 1, 2023
1 parent c0648c5 commit 65f1ef2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 47 deletions.
3 changes: 2 additions & 1 deletion webapp/src/Entity/Contest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions webapp/tests/Unit/Controller/Jury/ContestControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,6 @@ class ContestControllerTest extends JuryControllerTestCase
'allowJudge' => '1',
'color' => '#000000',
'lazyEvalResults' => '0']]]];

/**
* @param array<string, array<int, array<string, string|mixed[]>>> $addEntitiesFailure
*/
protected static array $addEntitiesFailure = ['Contest should not have multiple timezones.' => [['shortname' => 'tz',
'name' => 'Timezones',
'activatetimeString' => '1990-07-17 16:00:00 Africa/Douala',
Expand Down
40 changes: 1 addition & 39 deletions webapp/tests/Unit/Controller/Jury/JuryControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,13 @@ abstract class JuryControllerTestCase extends BaseTestCase
protected static array $addEntities = [];
protected static array $addEntitiesCount = [];
protected static array $addEntitiesShown = [];
/**
* @var array<string, array<int, mixed[]>> $addEntitiesFailure
*/
protected static array $addEntitiesFailure = [];
/**
* @var array<int, array<string, string>> $addEntitiesNonLocal
*/
protected static array $addEntitiesNonLocal = [];
/**
* @var array<string, array<int, array<string, string>>> $addEntitiesFailureNonLocal
*/
protected static array $addEntitiesFailureNonLocal = [];
protected static ?string $defaultEditEntityName = null;
protected static array $specialFieldOnlyUpdate = [];
protected static array $editEntitiesSkipFields = [];
/**
* @var array<int, string> $overviewSingleNotShown
*/
protected static array $overviewSingleNotShown = [];
/**
* @var array<int, string> $overviewGeneralNotShown
*/
protected static array $overviewGeneralNotShown = [];

protected function setUp(): void
Expand Down Expand Up @@ -307,8 +292,6 @@ protected function helperSubmitFields(array $element): Crawler {

/**
* Test that admin can add a new entity for this controller.
* @param array<string, string|array<string, bool>> $element
* @param array<string, string|mixed[]> $expected
* @dataProvider provideAddCorrectEntities
*/
public function testCheckAddEntityAdmin(array $element, array $expected): void
Expand Down Expand Up @@ -349,7 +332,6 @@ public function testCheckAddEntityAdmin(array $element, array $expected): void

/**
* Test failures when the admin provides wrong data.
* @param array<string, string|array<string, bool>> $element
* @dataProvider provideAddFailureEntities
*/
public function testCheckAddEntityAdminFailure(array $element, string $message): void
Expand All @@ -369,8 +351,6 @@ public function testCheckAddEntityAdminFailure(array $element, string $message):
/**
* Test that admin can add edit an entity for this controller.
*
* @param array<int, string> $formDataKeys
* @param array<int, mixed[]> $formDataValues
* @dataProvider provideEditCorrectEntities
*/
public function testCheckEditEntityAdminCorrect(array $formDataKeys, array $formDataValues): void
Expand Down Expand Up @@ -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 . '")');
}
}
Expand All @@ -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<int, string> $formDataKeys
* @param array<int, mixed> $formDataValues
* @dataProvider provideEditFailureEntities
*/
public function testCheckEditEntityAdminFailure(array $formDataKeys, array $formDataValues, string $message): void
Expand Down Expand Up @@ -497,18 +472,14 @@ 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];
}
}
}

/**
* @param array<string, string|bool|array<string, bool>> $overWriteValues
* @return array<int, array<string, string|bool|array<string, bool>>>
*/
protected function helperProvideMergeAddEntity(array $overWriteValues): array
{
$combinedValues = [];
Expand All @@ -522,20 +493,11 @@ protected function helperProvideMergeAddEntity(array $overWriteValues): array
return [$combinedValues, $overWriteValues];
}

/**
* @param array<string, string|bool|array<string, bool>> $entity
* @param array<string, string|bool|array<string, bool>> $expected
* @return array<int, array<string, string|bool|array<string, bool>>>
*/
protected function helperProvideTranslateAddEntity(array $entity, array $expected): array
{
return [$entity, $expected];
}

/**
* @param array<string, mixed> $element
* @return array<int, array<int, mixed>>
*/
public function helperProvideMergeEditEntity(array $element): array
{
$formdataKeys = [];
Expand Down
3 changes: 0 additions & 3 deletions webapp/tests/Unit/Controller/Jury/UserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed[]> $addEntitiesFailure
*/
protected static array $addEntitiesFailure = ['Only alphanumeric characters and _-@. are allowed' => [['username' => '|user', 'name' => 'StartWith'],
['username' => 'user|', 'name' => 'EndWith'],
['username' => 'us er', 'name' => 'SpaceUsage'],
Expand Down

0 comments on commit 65f1ef2

Please sign in to comment.