55namespace  PhpList \WebFrontend \Tests \Unit \Controller ;
66
77use  PhpList \WebFrontend \Controller \AuthController ;
8- use  PhpList \WebFrontend \ Service \ ApiClient ;
8+ use  PhpList \RestApiClient \ Endpoint \ AuthClient ;
99use  PHPUnit \Framework \MockObject \MockObject ;
1010use  PHPUnit \Framework \TestCase ;
1111use  RuntimeException ;
1616
1717class  AuthControllerTest extends  TestCase
1818{
19-     private  ApiClient MockObject $ apiClient
19+     private  AuthClient MockObject $ apiClient
2020    private  AuthController $ controller
2121
2222    protected  function  setUp (): void 
2323    {
24-         $ this apiClient  = $ this createMock (ApiClient ::class);
24+         $ this apiClient  = $ this createMock (AuthClient ::class);
2525
2626        $ this controller  = $ this getMockBuilder (AuthController::class)
2727            ->setConstructorArgs ([$ this apiClient ])
@@ -118,14 +118,10 @@ public function testLoginWithPostRequestSuccess(): void
118118        ]);
119119        $ requestsetSession ($ session
120120
121-         $ this apiClient ->method ('authenticate ' )
121+         $ this apiClient ->method ('login ' )
122122            ->with ('testuser ' , 'testpass ' )
123123            ->willReturn (['key '  => 'test-token ' ]);
124124
125-         $ this apiClient ->expects ($ this once ())
126-             ->method ('setAuthToken ' )
127-             ->with ('test-token ' );
128- 
129125        $ response$ this controller ->login ($ request
130126
131127        $ this assertInstanceOf (RedirectResponse::class, $ response
@@ -147,14 +143,17 @@ public function testLoginWithPostRequestFailure(): void
147143        ]);
148144        $ requestsetSession ($ session
149145
150-         $ this apiClient ->method ('authenticate ' )
146+         $ this apiClient ->method ('login ' )
151147            ->with ('testuser ' , 'testpass ' )
152148            ->willThrowException (new  RuntimeException ('Invalid credentials ' ));
153149
154150        $ response$ this controller ->login ($ request
155151
156152        $ this assertStringContainsString ('auth/login.html.twig ' , $ responsegetContent ());
157-         $ this assertStringContainsString ('Invalid credentials ' , $ responsegetContent ());
153+         $ this assertStringContainsString (
154+             'Invalid credentials or server error: Invalid credentials ' ,
155+             $ responsegetContent (),
156+         );
158157    }
159158
160159    public  function  testLoginWithExistingSession (): void 
0 commit comments