Skip to content

Commit

Permalink
tests: add test for magicLinkDisabled
Browse files Browse the repository at this point in the history
  • Loading branch information
datamweb committed Aug 9, 2023
1 parent 0961dc0 commit 44ca768
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/Controllers/MagicLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
);
}
}

0 comments on commit 44ca768

Please sign in to comment.