From cf141c36b035fdae07cab8934972f09597debdec Mon Sep 17 00:00:00 2001 From: Christian Hartmann Date: Sun, 27 Oct 2024 20:57:22 +0100 Subject: [PATCH] fix Signed-off-by: Christian Hartmann --- tests/Unit/Controller/ApiControllerTest.php | 32 ++++----------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/tests/Unit/Controller/ApiControllerTest.php b/tests/Unit/Controller/ApiControllerTest.php index 4369d18bf..f3322d399 100644 --- a/tests/Unit/Controller/ApiControllerTest.php +++ b/tests/Unit/Controller/ApiControllerTest.php @@ -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); @@ -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() {