2222use Mezzio \Template \TemplateRendererInterface ;
2323use PHPUnit \Framework \MockObject \Exception as MockObjectException ;
2424use PHPUnit \Framework \MockObject \MockObject ;
25+ use PHPUnit \Framework \MockObject \Stub ;
2526use Psr \Http \Message \ServerRequestInterface ;
2627
2728class PostAccountEditHandlerTest extends UnitTest
2829{
29- private MockObject &AdminServiceInterface $ adminService ;
30- private MockObject &RouterInterface $ router ;
31- private MockObject &TemplateRendererInterface $ template ;
32- private MockObject &AuthenticationServiceInterface $ authenticationService ;
33- private MockObject &AccountForm $ accountForm ;
34- private MockObject &ChangePasswordForm $ changePasswordForm ;
30+ private Stub &AdminServiceInterface $ adminService ;
31+ private Stub &RouterInterface $ router ;
32+ private Stub &TemplateRendererInterface $ template ;
33+ private Stub &AuthenticationServiceInterface $ authenticationService ;
34+ private Stub &AccountForm $ accountForm ;
35+ private Stub &ChangePasswordForm $ changePasswordForm ;
3536 private MockObject &FlashMessengerInterface $ messenger ;
3637 private Logger $ logger ;
37- private MockObject &AdminIdentity $ identity ;
38- private MockObject &ServerRequestInterface $ request ;
38+ private Stub &AdminIdentity $ identity ;
39+ private Stub &ServerRequestInterface $ request ;
3940
40- private MockObject &Admin $ admin ;
41+ private Stub &Admin $ admin ;
4142
4243 /**
4344 * @throws MockObjectException
@@ -46,16 +47,16 @@ public function setUp(): void
4647 {
4748 parent ::setUp ();
4849
49- $ this ->adminService = $ this ->createMock (AdminServiceInterface::class);
50- $ this ->router = $ this ->createMock (RouterInterface::class);
51- $ this ->template = $ this ->createMock (TemplateRendererInterface::class);
52- $ this ->authenticationService = $ this ->createMock (AuthenticationServiceInterface::class);
53- $ this ->accountForm = $ this ->createMock (AccountForm::class);
54- $ this ->changePasswordForm = $ this ->createMock (ChangePasswordForm::class);
50+ $ this ->adminService = $ this ->createStub (AdminServiceInterface::class);
51+ $ this ->router = $ this ->createStub (RouterInterface::class);
52+ $ this ->template = $ this ->createStub (TemplateRendererInterface::class);
53+ $ this ->authenticationService = $ this ->createStub (AuthenticationServiceInterface::class);
54+ $ this ->accountForm = $ this ->createStub (AccountForm::class);
55+ $ this ->changePasswordForm = $ this ->createStub (ChangePasswordForm::class);
5556 $ this ->messenger = $ this ->createMock (FlashMessengerInterface::class);
56- $ this ->identity = $ this ->createMock (AdminIdentity::class);
57- $ this ->request = $ this ->createMock (ServerRequestInterface::class);
58- $ this ->admin = $ this ->createMock (Admin::class);
57+ $ this ->identity = $ this ->createStub (AdminIdentity::class);
58+ $ this ->request = $ this ->createStub (ServerRequestInterface::class);
59+ $ this ->admin = $ this ->createStub (Admin::class);
5960 $ this ->logger = new Logger ([
6061 'writers ' => [
6162 'FileWriter ' => [
@@ -71,6 +72,7 @@ public function testInvalidAccountFormDataProvidedWillReturnHtmlResponse(): void
7172 $ this ->request ->method ('getParsedBody ' )->willReturn (['test ' ]);
7273 $ this ->authenticationService ->method ('getIdentity ' )->willReturn ($ this ->identity );
7374 $ this ->accountForm ->method ('isValid ' )->willReturn (false );
75+ $ this ->messenger ->expects ($ this ->never ())->method ('addError ' );
7476
7577 $ handler = new PostEditAccountHandler (
7678 $ this ->adminService ,
0 commit comments