Skip to content

Commit 44ca768

Browse files
committed
tests: add test for magicLinkDisabled
1 parent 0961dc0 commit 44ca768

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/Controllers/MagicLinkTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,36 @@ public function testBackToLoginLinkOnPage(): void
120120
$result = $this->get('/login/magic-link');
121121
$this->assertStringContainsString(lang('Auth.backToLogin'), $result->getBody());
122122
}
123+
124+
public function testMagicLinkRedirectsIfNotAllowed(): void
125+
{
126+
$config = config('Auth');
127+
$config->allowMagicLinkLogins = false;
128+
Factories::injectMock('config', 'Auth', $config);
129+
130+
$result = $this->withSession()->get('/login/magic-link');
131+
132+
$result->assertStatus(302);
133+
$result->assertRedirect();
134+
$result->assertSessionHas(
135+
'error',
136+
lang('Auth.magicLinkDisabled'),
137+
);
138+
}
139+
140+
public function testMagicLinkActionRedirectsIfNotAllowed(): void
141+
{
142+
$config = config('Auth');
143+
$config->allowMagicLinkLogins = false;
144+
Factories::injectMock('config', 'Auth', $config);
145+
146+
$result = $this->withSession()->post('/login/magic-link');
147+
148+
$result->assertStatus(302);
149+
$result->assertRedirect();
150+
$result->assertSessionHas(
151+
'error',
152+
lang('Auth.magicLinkDisabled'),
153+
);
154+
}
123155
}

0 commit comments

Comments
 (0)