Skip to content

Commit

Permalink
fix existing tests by adding AllowEdit
Browse files Browse the repository at this point in the history
Signed-off-by: Timotheus Pokorra <[email protected]>
  • Loading branch information
tpokorra committed Jan 3, 2025
1 parent ebad765 commit 2ad275c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions tests/Unit/Controller/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ public function dataTestCreateNewForm() {
'submissionMessage' => null,
'fileId' => null,
'fileFormat' => null,
'allowEdit' => null,
]]
];
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/FormsMigratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function dataExport() {
"state": 0,
"isAnonymous": false,
"submitMultiple": false,
"allowEdit": false,
"showExpiration": false,
"lastUpdated": 123456789,
"submissionMessage": "Back to website",
Expand Down Expand Up @@ -179,6 +180,7 @@ public function testExport(string $expectedJson) {
$form->setExpires(0);
$form->setIsAnonymous(false);
$form->setSubmitMultiple(false);
$form->setAllowEdit(false);
$form->setShowExpiration(false);
$form->setLastUpdated(123456789);
$form->setSubmissionMessage('Back to website');
Expand Down Expand Up @@ -251,7 +253,7 @@ public function testExport(string $expectedJson) {
public function dataImport() {
return [
'exactlyOneOfEach' => [
'$inputJson' => '[{"title":"Link","description":"","created":1646251830,"access":{"permitAllUsers":false,"showToAllUsers":false},"expires":0,"state":0,"isAnonymous":false,"submitMultiple":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"}]}]}]'
'$inputJson' => '[{"title":"Link","description":"","created":1646251830,"access":{"permitAllUsers":false,"showToAllUsers":false},"expires":0,"state":0,"isAnonymous":false,"submitMultiple":false,"allowEdit":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"}]}]}]'
]
];
}
Expand Down
14 changes: 13 additions & 1 deletion tests/Unit/Service/FormsServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function microtime(bool|float $asFloat = false) {
use OCA\Forms\Db\ShareMapper;
use OCA\Forms\Db\Submission;
use OCA\Forms\Db\SubmissionMapper;
use OCA\Forms\Db\AnswerMapper;
use OCA\Forms\Service\CirclesService;
use OCA\Forms\Service\ConfigService;
use OCA\Forms\Service\FormsService;
Expand Down Expand Up @@ -85,6 +86,9 @@ class FormsServiceTest extends TestCase {
/** @var SubmissionMapper|MockObject */
private $submissionMapper;

/** @var AnswerMapper|MockObject */
private $answerMapper;

/** @var ConfigService|MockObject */
private $configService;

Expand Down Expand Up @@ -114,6 +118,7 @@ public function setUp(): void {
$this->questionMapper = $this->createMock(QuestionMapper::class);
$this->shareMapper = $this->createMock(ShareMapper::class);
$this->submissionMapper = $this->createMock(SubmissionMapper::class);
$this->answerMapper = $this->createMock(AnswerMapper::class);
$this->configService = $this->createMock(ConfigService::class);

$this->groupManager = $this->createMock(IGroupManager::class);
Expand Down Expand Up @@ -147,6 +152,7 @@ public function setUp(): void {
$this->questionMapper,
$this->shareMapper,
$this->submissionMapper,
$this->answerMapper,
$this->configService,
$this->groupManager,
$this->userManager,
Expand Down Expand Up @@ -243,7 +249,8 @@ public function dataGetForm() {
'submissionMessage' => null,
'fileId' => null,
'fileFormat' => null,
'permissions' => Constants::PERMISSION_ALL
'permissions' => Constants::PERMISSION_ALL,
'allowEdit' => false,
]]
];
}
Expand Down Expand Up @@ -456,6 +463,7 @@ public function dataGetPublicForm() {
'submit'
],
'submissionMessage' => null,
'allowEdit' => false,
]]
];
}
Expand Down Expand Up @@ -622,6 +630,7 @@ public function testGetPermissions_NotLoggedIn() {
$this->questionMapper,
$this->shareMapper,
$this->submissionMapper,
$this->answerMapper,
$this->configService,
$this->groupManager,
$this->userManager,
Expand Down Expand Up @@ -861,6 +870,7 @@ public function testPublicCanSubmit() {
$this->questionMapper,
$this->shareMapper,
$this->submissionMapper,
$this->answerMapper,
$this->configService,
$this->groupManager,
$this->userManager,
Expand Down Expand Up @@ -972,6 +982,7 @@ public function testHasUserAccess_NotLoggedIn() {
$this->questionMapper,
$this->shareMapper,
$this->submissionMapper,
$this->answerMapper,
$this->configService,
$this->groupManager,
$this->userManager,
Expand Down Expand Up @@ -1203,6 +1214,7 @@ public function testNotifyNewSubmission($shares, $shareNotifications) {
$this->questionMapper,
$this->shareMapper,
$this->submissionMapper,
$this->answerMapper,
$this->configService,
$this->groupManager,
$this->userManager,
Expand Down

0 comments on commit 2ad275c

Please sign in to comment.