Skip to content

Commit 890e8e1

Browse files
Test user deletion using Dusk
1 parent ee0a05e commit 890e8e1

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

.env.travis

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ APP_DEBUG=true
55
APP_LOG_LEVEL=debug
66
APP_URL=http://localhost:8000
77

8-
DB_CONNECTION=mysql
8+
DB_CONNECTION=testing
99
DB_HOST=127.0.0.1
1010
DB_PORT=3306
1111
DB_DATABASE=budget

tests/Browser/DeleteUserTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Tests\Browser;
4+
5+
use App\Models\User;
6+
use Illuminate\Foundation\Testing\DatabaseMigrations;
7+
use Illuminate\Support\Facades\Hash;
8+
use Laravel\Dusk\Browser;
9+
use Tests\DuskTestCase;
10+
11+
class DeleteUserTest extends DuskTestCase
12+
{
13+
public function testSuccess(): void
14+
{
15+
$password = 'hoi';
16+
17+
$user = factory(User::class)->create([
18+
'password' => Hash::make($password)
19+
]);
20+
21+
$this->browse(function (Browser $browser) use ($user, $password) {
22+
$browser
23+
->assertGuest()
24+
->visit('/login')
25+
->type('email', $user->email)
26+
->type('password', $password)
27+
->press('Log in')
28+
->assertAuthenticated()
29+
->visit('/settings/account')
30+
->press('Delete')
31+
->press('Yes, I am sure')
32+
->assertGuest();
33+
});
34+
}
35+
}

0 commit comments

Comments
 (0)