Skip to content

Commit 59282d7

Browse files
committed
test: update form tests to include lockedBy and lockedUntil fields
Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
1 parent 57bc346 commit 59282d7

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

tests/Unit/Controller/ApiControllerTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ public function dataTestCreateNewForm() {
407407
'submissionMessage' => null,
408408
'fileId' => null,
409409
'fileFormat' => null,
410-
'allowEditSubmissions' => false
410+
'allowEditSubmissions' => false,
411+
'lockedBy' => null,
412+
'lockedUntil' => null,
411413
]]
412414
];
413415
}
@@ -977,6 +979,11 @@ public function testTransferNewOwnerNotFound() {
977979
->with(1)
978980
->willReturn($form);
979981

982+
$this->formsService
983+
->method('canEditForm')
984+
->with($form)
985+
->willReturn(true);
986+
980987
$this->userManager->expects($this->once())
981988
->method('get')
982989
->with('newOwner')
@@ -997,6 +1004,11 @@ public function testTransferOwner() {
9971004
->with(1)
9981005
->willReturn($form);
9991006

1007+
$this->formsService
1008+
->method('canEditForm')
1009+
->with($form)
1010+
->willReturn(true);
1011+
10001012
$newOwner = $this->createMock(IUser::class);
10011013
$this->userManager->expects($this->once())
10021014
->method('get')

tests/Unit/FormsMigratorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
99

1010
use OCA\Forms\Db\AnswerMapper;
1111

12-
// use OCA\Forms\Db\Answer;
1312
use OCA\Forms\Db\Form;
1413
use OCA\Forms\Db\FormMapper;
1514
use OCA\Forms\Db\OptionMapper;
16-
// use OCA\Forms\Db\Option;
1715
use OCA\Forms\Db\QuestionMapper;
18-
// use OCA\Forms\Db\Question;
1916
use OCA\Forms\Db\SubmissionMapper;
20-
// use OCA\Forms\Db\Submission;
2117
use OCA\Forms\FormsMigrator;
2218
use OCA\Forms\Service\FormsService;
2319
use OCA\Forms\Service\SubmissionService;
@@ -106,6 +102,8 @@ public function dataExport() {
106102
},
107103
"expires": 0,
108104
"state": 0,
105+
"lockedBy": null,
106+
"lockedUntil": null,
109107
"isAnonymous": false,
110108
"submitMultiple": false,
111109
"allowEditSubmissions": false,
@@ -168,6 +166,8 @@ public function testExport(string $expectedJson) {
168166
$form = new Form();
169167
$form->setId(42);
170168
$form->setState(0);
169+
$form->setLockedBy(null);
170+
$form->setLockedBy(null);
171171
$form->setHash('abcdefg');
172172
$form->setTitle('Link');
173173
$form->setDescription('');
@@ -253,7 +253,7 @@ public function testExport(string $expectedJson) {
253253
public function dataImport() {
254254
return [
255255
'exactlyOneOfEach' => [
256-
'$inputJson' => '[{"title":"Link","description":"","created":1646251830,"access":{"permitAllUsers":false,"showToAllUsers":false},"expires":0,"state":0,"isAnonymous":false,"submitMultiple":false,"allowEditSubmissions":false,"showExpiration":false,"lastUpdated":123456789,"questions":[{"id":14,"order":2,"type":"multiple","isRequired":false,"text":"checkbox","description":"huhu","extraSettings":{},"options":[{"text":"ans1"}]}],"submissions":[{"userId":"anyUser@localhost","timestamp":1651354059,"answers":[{"questionId":14,"text":"ans1"}]}]}]'
256+
'$inputJson' => '[{"title":"Link","description":"","created":1646251830,"access":{"permitAllUsers":false,"showToAllUsers":false},"expires":0,"state":0,"lockedBy":null,"lockedUntil":null,"isAnonymous":false,"submitMultiple":false,"allowEditSubmissions":false,"showExpiration":false,"lastUpdated":123456789,"questions":[{"id":14,"order":2,"type":"multiple","isRequired":false,"text":"checkbox","description":"huhu","extraSettings":{},"options":[{"text":"ans1"}]}],"submissions":[{"userId":"anyUser@localhost","timestamp":1651354059,"answers":[{"questionId":14,"text":"ans1"}]}]}]'
257257
]
258258
];
259259
}

tests/Unit/Service/FormsServiceTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ public function dataGetForm() {
244244
'fileId' => null,
245245
'fileFormat' => null,
246246
'permissions' => Constants::PERMISSION_ALL,
247-
'allowEditSubmissions' => false
247+
'allowEditSubmissions' => false,
248+
'lockedBy' => null,
249+
'lockedUntil' => null,
248250
]]
249251
];
250252
}
@@ -358,6 +360,8 @@ public function dataGetPartialForm() {
358360
'permissions' => Constants::PERMISSION_ALL,
359361
'submissionCount' => 123,
360362
'partial' => true,
363+
'lockedBy' => null,
364+
'lockedUntil' => null,
361365
]]
362366
];
363367
}
@@ -397,6 +401,8 @@ public function dataGetPartialFormShared() {
397401
'submissionCount' => 123,
398402
'state' => 0,
399403
'partial' => true,
404+
'lockedBy' => null,
405+
'lockedUntil' => null,
400406
]]
401407
];
402408
}
@@ -458,6 +464,8 @@ public function dataGetPublicForm() {
458464
],
459465
'submissionMessage' => null,
460466
'allowEditSubmissions' => false,
467+
'lockedBy' => null,
468+
'lockedUntil' => null,
461469
]]
462470
];
463471
}

0 commit comments

Comments
 (0)