@@ -147,6 +147,83 @@ public function testRegisterRedirectsToActionIfDefined(): void
147147 ]);
148148 }
149149
150+ public function testRegisteredButNotActivatedAndLogin (): void
151+ {
152+ // Ensure our action is defined
153+ $ config = config ('Auth ' );
154+ $ config ->actions ['register ' ] = EmailActivator::class;
155+ Factories::injectMock ('config ' , 'Auth ' , $ config );
156+
157+ $ result = $ this ->post ('/register ' , [
158+ 'email ' => 'foo@example.com ' ,
159+ 'username ' => 'foo ' ,
160+ 'password ' => 'abkdhflkjsdflkjasd;lkjf ' ,
161+ 'password_confirm ' => 'abkdhflkjsdflkjasd;lkjf ' ,
162+ ]);
163+
164+ // Should have been redirected to the action's page.
165+ $ result ->assertRedirectTo ('/auth/a/show ' );
166+
167+ // Not activated yet, but login again.
168+ $ result = $ this ->withSession ()->get ('/login ' );
169+
170+ // Should have been redirected to the action's page.
171+ $ result ->assertRedirectTo ('/auth/a/show ' );
172+ }
173+
174+ public function testRegisteredButNotActivatedAndRegisterAgain (): void
175+ {
176+ // Ensure our action is defined
177+ $ config = config ('Auth ' );
178+ $ config ->actions ['register ' ] = EmailActivator::class;
179+ Factories::injectMock ('config ' , 'Auth ' , $ config );
180+
181+ $ password = 'abkdhflkjsdflkjasd;lkjf ' ;
182+
183+ $ result = $ this ->post ('/register ' , [
184+ 'email ' => 'foo@example.com ' ,
185+ 'username ' => 'foo ' ,
186+ 'password ' => $ password ,
187+ 'password_confirm ' => $ password ,
188+ ]);
189+
190+ // Should have been redirected to the action's page.
191+ $ result ->assertRedirectTo ('/auth/a/show ' );
192+
193+ // Not activated yet, but register again.
194+ $ result = $ this ->withSession ()->get ('/register ' );
195+
196+ // Should have been redirected to the action's page.
197+ $ result ->assertRedirectTo ('/auth/a/show ' );
198+ }
199+
200+ public function testRegisteredAndSessionExpiredAndLogin (): void
201+ {
202+ // Ensure our action is defined
203+ $ config = config ('Auth ' );
204+ $ config ->actions ['register ' ] = EmailActivator::class;
205+ Factories::injectMock ('config ' , 'Auth ' , $ config );
206+
207+ $ result = $ this ->post ('/register ' , [
208+ 'email ' => 'foo@example.com ' ,
209+ 'username ' => 'foo ' ,
210+ 'password ' => 'abkdhflkjsdflkjasd;lkjf ' ,
211+ 'password_confirm ' => 'abkdhflkjsdflkjasd;lkjf ' ,
212+ ]);
213+
214+ // Should have been redirected to the action's page.
215+ $ result ->assertRedirectTo ('/auth/a/show ' );
216+
217+ // Not activated yet, and do not set Session (= the session is expired) and login again.
218+ $ result = $ this ->post ('/login ' , [
219+ 'email ' => 'foo@example.com ' ,
220+ 'password ' => 'abkdhflkjsdflkjasd;lkjf ' ,
221+ ]);
222+
223+ // Should have been redirected to the action's page.
224+ $ result ->assertRedirectTo ('/auth/a/show ' );
225+ }
226+
150227 public function testRegisterRedirectsIfLoggedIn (): void
151228 {
152229 // log them in
0 commit comments