Skip to content

Commit

Permalink
Fix Unit tests (unknown type to string)
Browse files Browse the repository at this point in the history
Apparantly the upgraded dependencies can now also verify the type.
  • Loading branch information
vmcj committed Jun 26, 2024
1 parent 0a68916 commit e1737bb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function testAddInvalidData(string $user, array $dataToSend, string $expe
public function provideAddInvalidData(): Generator
{
yield ['demo', [], ""];
yield ['demo', ['invalidfield' => 'value'], "/text:\n.*This value should be of type unknown./"];
yield ['demo', ['invalidfield' => 'value'], "/text:\n.*This value should be of type string./"];
yield ['demo', ['text' => 'This is a clarification', 'from_team_id' => 'domjudge'], "Can not create a clarification from a different team."];
yield ['demo', ['text' => 'This is a clarification', 'to_team_id' => 'exteam'], "Can not create a clarification that is sent to a team."];
yield ['demo', ['text' => 'This is a clarification', 'problem_id' => 'prob'], "Problem 'prob' not found."];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function provideChangeTimes(): Generator

// General tests
yield [[], 400, ''];
yield [['dummy' => 'dummy'], 400, "This value should be of type unknown."];
yield [['dummy' => 'dummy'], 400, "This value should be of type string."];
yield [['id' => 1], 400, 'Missing \"start_time\" or \"scoreboard_thaw_time\" in request.'];
yield [['id' => 1, 'start_time' => null, 'scoreboard_thaw_time' => date('Y-m-d\TH:i:s', strtotime('+15 seconds'))], 400, 'Setting both \"start_time\" and \"scoreboard_thaw_time\" at the same time is not allowed.'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function provideAddInvalidData(): Generator
yield ['demo', ['problem_id' => 'hello', 'language_id' => 'cpp', 'id' => '123'], "A team can not assign id."];
yield ['demo', ['problem_id' => 'hello', 'language_id' => 'cpp', 'time' => '2021-01-01T00:00:00'], "A team can not assign time."];
yield ['demo', ['problem_id' => 'hello', 'language_id' => 'cpp', 'files' => []], "No files specified."];
yield ['demo', ['problem_id' => 'hello', 'language_id' => 'cpp', 'files' => [['invalidkey' => 'somevalue']]], "/files\[0\].data:\n.*This value should be of type unknown./"];
yield ['demo', ['problem_id' => 'hello', 'language_id' => 'cpp', 'files' => [['invalidkey' => 'somevalue']]], "/files\[0\].data:\n.*This value should be of type string./"];
yield [
'demo',
['problem_id' => 'hello', 'language_id' => 'cpp', 'files' => 'this is not an array'],
Expand Down
2 changes: 1 addition & 1 deletion webapp/tests/Unit/Controller/API/UserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ public function testUpdateNoId(): void
];

$response = $this->verifyApiJsonResponse('PUT', $this->helperGetEndpointURL($this->apiEndpoint) . '/someid', 400, 'admin', $data);
static::assertMatchesRegularExpression('/id:\n.*This value should be of type unknown./', $response['message']);
static::assertMatchesRegularExpression('/id:\n.*This value should be of type string./', $response['message']);
}
}

0 comments on commit e1737bb

Please sign in to comment.