diff --git a/tests/Controllers/MagicLinkTest.php b/tests/Controllers/MagicLinkTest.php index 7bf92fc6b..dfb963993 100644 --- a/tests/Controllers/MagicLinkTest.php +++ b/tests/Controllers/MagicLinkTest.php @@ -120,4 +120,36 @@ public function testBackToLoginLinkOnPage(): void $result = $this->get('/login/magic-link'); $this->assertStringContainsString(lang('Auth.backToLogin'), $result->getBody()); } + + public function testMagicLinkRedirectsIfNotAllowed(): void + { + $config = config('Auth'); + $config->allowMagicLinkLogins = false; + Factories::injectMock('config', 'Auth', $config); + + $result = $this->withSession()->get('/login/magic-link'); + + $result->assertStatus(302); + $result->assertRedirect(); + $result->assertSessionHas( + 'error', + lang('Auth.magicLinkDisabled'), + ); + } + + public function testMagicLinkActionRedirectsIfNotAllowed(): void + { + $config = config('Auth'); + $config->allowMagicLinkLogins = false; + Factories::injectMock('config', 'Auth', $config); + + $result = $this->withSession()->post('/login/magic-link'); + + $result->assertStatus(302); + $result->assertRedirect(); + $result->assertSessionHas( + 'error', + lang('Auth.magicLinkDisabled'), + ); + } }