Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit 6e3b1a8

Browse files
author
Holger Lösken
committed
More testing
1 parent c9a2d2f commit 6e3b1a8

5 files changed

Lines changed: 68 additions & 0 deletions

File tree

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: codedge

phpunit.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
<env name="APP_DEBUG" value="true"/>
2626
<env name="APP_KEY" value="base64:mIRM5Fpb6DtuRIejBwkqpt3c/ovlFZsSpo66efwo3g0="/>
2727
<env name="CACHE_DRIVER" value="array"/>
28+
<env name="SESSION_DRIVER" value="array"/>
29+
<env name="QUEUE_DRIVER" value="sync"/>
2830
<env name="MAIL_DRIVER" value="array"/>
2931
</php>
3032
</phpunit>

src/ServiceProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function register()
6868
$this->app->bind(SettingsRepository::class, function () {
6969
return new SettingsRepository(new Filesystem());
7070
});
71+
72+
$this->app->bind(MagicLinkManager::class, function () {
73+
return new MagicLinkManager(new Filesystem());
74+
});
7175
}
7276

7377
private function bootNavigation(): void

tests/Auth/LoginTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Codedge\MagicLink\Tests;
4+
5+
class LoginTest extends TestCase
6+
{
7+
/** @test */
8+
public function can_see_magic_link_link(): void
9+
{
10+
$this->get(cp_route('login'))
11+
->assertSee('Send Magic Link')
12+
->assertOk();
13+
}
14+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Codedge\MagicLink\Tests\MagicLink;
4+
5+
use Codedge\MagicLink\Tests\TestCase;
6+
7+
class MagicLinkFormTest extends TestCase
8+
{
9+
/** @test */
10+
public function can_show_magic_link_form(): void
11+
{
12+
$this->get(route('magiclink.show-send-link-form'))
13+
->assertOk()
14+
->assertSee(__('magiclink::web.back_to_classic_login'));
15+
}
16+
17+
/** @test */
18+
public function cannot_get_link_for_invalid_address(): void
19+
{
20+
$payload = [
21+
'email' => 'wrong-email-format'
22+
];
23+
24+
$this->post(route('magiclink.send-link'), $payload)
25+
->assertSessionHasErrors(['email']);
26+
27+
$payload = [
28+
'email' => ''
29+
];
30+
31+
$this->post(route('magiclink.send-link'), $payload)
32+
->assertSessionHasErrors(['email']);
33+
}
34+
35+
// /** @test */
36+
// public function can_request_link_for_non_existing_user(): void
37+
// {
38+
// $payload = [
39+
// 'email' => 'john@doe.com'
40+
// ];
41+
//
42+
// $this->post(route('magiclink.send-link'), $payload)->assertOk();
43+
//
44+
//
45+
// }
46+
47+
}

0 commit comments

Comments
 (0)