request = $this->createMock(IRequest::class); $this->mandatoryTwoFactor = $this->createMock(MandatoryTwoFactor::class); $this->controller = new TwoFactorSettingsController( 'settings', $this->request, $this->mandatoryTwoFactor ); } public function testIndex(): void { $state = new EnforcementState(true); $this->mandatoryTwoFactor->expects($this->once()) ->method('getState') ->willReturn($state); $expected = new JSONResponse($state); $resp = $this->controller->index(); $this->assertEquals($expected, $resp); } public function testUpdate(): void { $state = new EnforcementState(true); $this->mandatoryTwoFactor->expects($this->once()) ->method('setState') ->with($this->equalTo(new EnforcementState(true))); $this->mandatoryTwoFactor->expects($this->once()) ->method('getState') ->willReturn($state); $expected = new JSONResponse($state); $resp = $this->controller->update(true); $this->assertEquals($expected, $resp); } }