Skip to content

Commit

Permalink
🧾 Update tests to expect helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ikramsyakir committed Jan 18, 2025
1 parent b37f173 commit b3088b5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
3 changes: 2 additions & 1 deletion tests/Feature/Auth/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
]);

$this->assertAuthenticated();
$response->assertJson($response->json());

expect($response->json())->toBeArray();
});

test('users can not authenticate with invalid password', function () {
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Auth/PasswordUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
]);

$response->assertSessionHasNoErrors();
$response->assertJson($response->json());

$this->assertTrue(Hash::check('new-password', $user->refresh()->password));
expect($response->json())->toBeArray()
->and(Hash::check('new-password', $user->refresh()->password))->toBeTrue();
});

test('correct password must be provided to update password', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Auth/RegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
'password_confirmation' => 'password',
]);

$response->assertJson($response->json());
expect($response->json())->toBeArray();
$this->assertAuthenticated();
});
24 changes: 12 additions & 12 deletions tests/Feature/Profiles/ProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
]);

$response->assertSessionHasNoErrors();
$response->assertJson($response->json());

$user = $user->refresh();

$this->assertSame('Test User', $user->name);
$this->assertSame('[email protected]', $user->email);
$this->assertNull($user->email_verified_at);
expect($response->json())->toBeArray()
->and($user->refresh())
->name->toBe('Test User')
->email->toBe('[email protected]')->toContain('@')
->email_verified_at->toBeNull();
});

test('email verification status is unchanged when the email address is unchanged', function () {
Expand All @@ -45,9 +44,10 @@
]);

$response->assertSessionHasNoErrors();
$response->assertJson($response->json());

$this->assertNotNull($user->refresh()->email_verified_at);
expect($response->json())->toBeArray()
->and($user->refresh())
->email_verified_at->not->toBeNull();
});

test('user can delete their account', function () {
Expand All @@ -60,10 +60,10 @@
]);

$response->assertSessionHasNoErrors();
$response->assertJson($response->json());

$this->assertGuest();
$this->assertNull($user->fresh());

expect($response->json())->toBeArray()
->and($user->refresh()->first())->toBeNull();
});

test('correct password must be provided to delete account', function () {
Expand All @@ -78,5 +78,5 @@

$response->assertSessionHasErrors('password');

$this->assertNotNull($user->fresh());
expect($user->fresh())->not->toBeNull();
});
7 changes: 7 additions & 0 deletions tests/Unit/ArchitectureTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

arch('does not use debugging functions')
->expect(['dd', 'dump', 'ray', 'ds'])
->not->toBeUsed();

// arch()->preset()->laravel();

0 comments on commit b3088b5

Please sign in to comment.