Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hartmann <[email protected]>
  • Loading branch information
Chartman123 committed Oct 27, 2024
1 parent 3b9c974 commit cf141c3
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions tests/Unit/Controller/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,30 +407,6 @@ public function dataTestCreateNewForm() {
* @dataProvider dataTestCreateNewForm()
*/
public function testCreateNewForm($expectedForm) {
// Create a partial mock, as we only test newForm and not getForm
/** @var ApiController|MockObject */
$apiController = $this->getMockBuilder(ApiController::class)
->onlyMethods(['getForm'])
->setConstructorArgs(['forms',
$this->request,
$this->createUserSession(),
$this->answerMapper,
$this->formMapper,
$this->optionMapper,
$this->questionMapper,
$this->shareMapper,
$this->submissionMapper,
$this->configService,
$this->formsService,
$this->submissionService,
$this->l10n,
$this->logger,
$this->userManager,
$this->storage,
$this->uploadedFileMapper,
$this->mimeTypeDetector,
])->getMock();

$this->configService->expects($this->once())
->method('canCreateForms')
->willReturn(true);
Expand All @@ -442,14 +418,18 @@ public function testCreateNewForm($expectedForm) {
// TODO fix test, currently unset because behaviour has changed
$expected['state'] = null;
$expected['lastUpdated'] = null;
$this->formMapper->expects($this->once())
$form = $this->formMapper->expects($this->once())
->method('insert')
->with(self::callback(self::createFormValidator($expected)))
->willReturnCallback(function ($form) {
$form->setId(7);
return $form;
});
$this->assertEquals(new DataResponse($expected, Http::STATUS_CREATED), $apiController->newForm());
$this->formsService->expects($this->once())
->method('getForm')
->with($form)
->willReturn(new DataResponse($expected, Http::STATUS_CREATED));
$this->assertEquals(new DataResponse($expected, Http::STATUS_CREATED), $this->apiController->newForm());
}

public function dataCloneForm_exceptions() {
Expand Down

0 comments on commit cf141c3

Please sign in to comment.