Skip to content

Commit 7b7bc21

Browse files
committed
wip
Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent 849d768 commit 7b7bc21

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

tests/Browser/Auth/AuthenticationTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
use App\Models\User;
44
use Illuminate\Support\Facades\RateLimiter;
55

6+
use function Pest\Laravel\actingAs;
7+
use function Pest\Laravel\assertAuthenticated;
8+
use function Pest\Laravel\assertGuest;
9+
610
test('login screen can be rendered', function () {
711
visit(route('login'))
812
->assertNoConsoleLogs()
@@ -22,7 +26,7 @@
2226
->assertNoConsoleLogs()
2327
->assertNoJavaScriptErrors();
2428

25-
$this->assertAuthenticated();
29+
assertAuthenticated();
2630
});
2731

2832
test('users can not authenticate with invalid password', function () {
@@ -37,13 +41,13 @@
3741
->assertNoConsoleLogs()
3842
->assertNoJavaScriptErrors();
3943

40-
$this->assertGuest();
44+
assertGuest();
4145
});
4246

4347
test('users can logout', function () {
4448
$user = User::factory()->create();
4549

46-
$this->actingAs($user);
50+
actingAs($user);
4751

4852
visit(route('dashboard'))
4953
->click($user->name)
@@ -52,7 +56,7 @@
5256
->assertNoConsoleLogs()
5357
->assertNoJavaScriptErrors();
5458

55-
$this->assertGuest();
59+
assertGuest();
5660
});
5761

5862
test('users are rate limited', function () {

tests/Browser/Auth/EmailVerificationTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
->assertNoJavaScriptErrors();
4141

4242
Event::assertDispatched(Verified::class);
43-
$this->assertTrue($user->fresh()->hasVerifiedEmail());
43+
expect($user->fresh()->hasVerifiedEmail())->toBeTrue();
4444
});
4545

4646
test('email is not verified with invalid hash', function () {
@@ -63,7 +63,7 @@
6363
->assertNoJavaScriptErrors();
6464

6565
Event::assertNotDispatched(Verified::class);
66-
$this->assertFalse($user->fresh()->hasVerifiedEmail());
66+
expect($user->fresh()->hasVerifiedEmail())->toBeFalse();
6767
});
6868

6969
test('email is not verified with invalid user id', function () {
@@ -86,7 +86,7 @@
8686
->assertNoJavaScriptErrors();
8787

8888
Event::assertNotDispatched(Verified::class);
89-
$this->assertFalse($user->fresh()->hasVerifiedEmail());
89+
expect($user->fresh()->hasVerifiedEmail())->toBeFalse();
9090
});
9191

9292
test('verified user is redirected to dashboard from verification prompt', function () {
@@ -128,5 +128,5 @@
128128
->assertNoJavaScriptErrors();
129129

130130
Event::assertNotDispatched(Verified::class);
131-
$this->assertTrue($user->fresh()->hasVerifiedEmail());
131+
expect($user->fresh()->hasVerifiedEmail())->toBeTrue();
132132
});

tests/Browser/Auth/RegistrationTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
use App\Models\User;
44

5+
use function Pest\Laravel\assertAuthenticated;
6+
use function Pest\Laravel\assertGuest;
7+
58
test('registration screen can be rendered', function () {
69
visit(route('register'))
710
->assertSee('Create an account')
@@ -21,7 +24,7 @@
2124
->assertNoConsoleLogs()
2225
->assertNoJavaScriptErrors();
2326

24-
$this->assertAuthenticated();
27+
assertAuthenticated();
2528
});
2629

2730
test('new user cannot be registered when email has already been taken', function () {
@@ -40,7 +43,7 @@
4043
->assertNoConsoleLogs()
4144
->assertNoJavaScriptErrors();
4245

43-
$this->assertGuest();
46+
assertGuest();
4447
});
4548

4649
test('new user cannot be registered when password does not match', function () {
@@ -54,5 +57,5 @@
5457
->assertNoConsoleLogs()
5558
->assertNoJavaScriptErrors();
5659

57-
$this->assertGuest();
60+
assertGuest();
5861
});

tests/Browser/DashboardTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
use App\Models\User;
44

5+
use function Pest\Laravel\actingAs;
6+
57
test('guests are redirected to the login page', function () {
68
visit(route('dashboard'))
79
->assertUrlIs(route('login'))
@@ -12,7 +14,7 @@
1214
});
1315

1416
test('authenticated users can visit the dashboard', function () {
15-
$this->actingAs(User::factory()->create());
17+
actingAs(User::factory()->create());
1618

1719
visit(route('dashboard'))
1820
->assertUrlIs(route('dashboard'))

0 commit comments

Comments
 (0)