File tree Expand file tree Collapse file tree
tests/php/Unit/Controller Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -478,6 +478,27 @@ public function testSetUserPolicyForTargetUserReturnsSavedResolvedPolicy(): void
478478 $ this ->assertSame ('ordered_numeric ' , $ response ->getData ()['policy ' ]['effectiveValue ' ]);
479479 }
480480
481+ public function testSetUserPolicyForTargetUserReturnsBadRequestWhenServiceBlocksSave (): void {
482+ $ this ->l10n
483+ ->expects ($ this ->once ())
484+ ->method ('t ' )
485+ ->with ('Saving a user preference is not allowed for signature_flow ' )
486+ ->willReturn ('Saving a user preference is not allowed for signature_flow ' );
487+
488+ $ this ->policyService
489+ ->expects ($ this ->once ())
490+ ->method ('saveUserPreferenceForUserId ' )
491+ ->with ('signature_flow ' , 'user1 ' , 'ordered_numeric ' )
492+ ->willThrowException (new \InvalidArgumentException ('Saving a user preference is not allowed for signature_flow ' ));
493+
494+ $ response = $ this ->controller ->setUserPolicyForUser ('user1 ' , 'signature_flow ' , 'ordered_numeric ' );
495+
496+ $ this ->assertSame (Http::STATUS_BAD_REQUEST , $ response ->getStatus ());
497+ $ this ->assertSame ([
498+ 'error ' => 'Saving a user preference is not allowed for signature_flow ' ,
499+ ], $ response ->getData ());
500+ }
501+
481502 public function testSetUserPreferenceReadsBodyParamsFromRequest (): void {
482503 $ request = $ this ->createMock (IRequest::class);
483504 $ request
You can’t perform that action at this time.
0 commit comments