Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera

uno-de-piera/UsersTableTest.php Secret

Created May 31, 2020
Embed
What would you like to do?
<?php
namespace Tests\Browser;
use App\User;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class UsersTableTest extends DuskTestCase
{
use DatabaseMigrations;
/**
* @group users
*/
public function testRouteProtected()
{
$this->browse(function (Browser $browser) {
$browser->visit('/users')
->assertPathIs('/login');
});
}
/**
* @group users
*/
public function testFindUserInTable()
{
$user = factory(User::class)->create([
'email' => 'dusk@cursosdesarrolloweb.es'
]);
$this->browse(function (Browser $browser) use($user) {
$browser->loginAs($user->id)
->visit('/users')
->with('.table', function (Browser $table) use ($user) {
$table->assertSee('dusk@cursosdesarrolloweb.es')
->clickLink('Detail')
->assertPathIs('/users/'.$user->id);
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment