Skip to content

Commit

Permalink
MDL-73155 qtype_essay: Coding style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Dec 2, 2021
1 parent a6e991c commit ff39641
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions question/type/essay/tests/edit_form_test.php
Expand Up @@ -65,8 +65,12 @@ protected function get_form($classname) {
$fakequestion->attachmentsrequired = 3;
$fakequestion->filetypeslist = '';

$form = new $classname(new moodle_url('/'), $fakequestion, $category,
new question_edit_contexts($syscontext));
$form = new $classname(
new moodle_url('/'),
$fakequestion,
$category,
new question_edit_contexts($syscontext)
);

return [$form, $category];
}
Expand All @@ -82,13 +86,15 @@ protected function get_form($classname) {
public function test_attachments_validation(int $allowed, int $required, array $expected): void {
list($form, $category) = $this->get_form('qtype_essay_edit_form');
$submitteddata = [
'category' => $category->id,
'questiontext' => ['text' => 'please writer an assay about ...',
'format' => FORMAT_HTML],
'responseformat' => 'editorfilepicker',
'responserequired' => '1',
'attachments' => $allowed,
'attachmentsrequired' => $required,
'category' => $category->id,
'questiontext' => [
'text' => 'please writer an assay about ...',
'format' => FORMAT_HTML,
],
'responseformat' => 'editorfilepicker',
'responserequired' => '1',
'attachments' => $allowed,
'attachmentsrequired' => $required,
];
$errors = $form->validation($submitteddata, []);
$this->assertArrayNotHasKey('attachments', $errors);
Expand All @@ -105,20 +111,20 @@ public function user_preference_provider(): array {
$valid = [];
$invalid = ['attachmentsrequired' => get_string('mustrequirefewer', 'qtype_essay')];
return [
'Attachments allowed=0, required=0, valid' => [0, 0, $valid],
'Attachments allowed=0, required=1, invalid, so required is set to 0 when saving' => [0, 1, $valid],
'Attachments allowed=0, required=2, invalid, so required is set to 0 when saving' => [0, 2, $valid],
'Attachments allowed=0, required=3, invalid, so required is set to 0 when saving' => [0, 3, $valid],
'Attachments allowed=0, required=0, valid' => [0, 0, $valid],
'Attachments allowed=0, required=1, invalid, so required is set to 0 when saving' => [0, 1, $valid],
'Attachments allowed=0, required=2, invalid, so required is set to 0 when saving' => [0, 2, $valid],
'Attachments allowed=0, required=3, invalid, so required is set to 0 when saving' => [0, 3, $valid],

'Attachments allowed=1, required=0, valid' => [1, 0, $valid],
'Attachments allowed=1, required=1, valid' => [1, 1, $valid],
'Attachments allowed=1, required=2, invalid' => [1, 2, $invalid],
'Attachments allowed=1, required=0, valid' => [1, 0, $valid],
'Attachments allowed=1, required=1, valid' => [1, 1, $valid],
'Attachments allowed=1, required=2, invalid' => [1, 2, $invalid],

'Attachments allowed=2, required=3, invalid' => [2, 3, $invalid],
'Attachments allowed=2, required=3, invalid' => [2, 3, $invalid],

'Attachments allowed=3, required=4, invalid' => [3, 4, $invalid],
'Attachments allowed=3, required=4, invalid' => [3, 4, $invalid],

'Attachments allowed=-1, required=4, valid' => [-1, 4, $valid],
'Attachments allowed=-1, required=4, valid' => [-1, 4, $valid],
];
}
}

0 comments on commit ff39641

Please sign in to comment.