Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera
Created May 31, 2020 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uno-de-piera/ce32895219389920933b0f51cf3582e6 to your computer and use it in GitHub Desktop.
Save uno-de-piera/ce32895219389920933b0f51cf3582e6 to your computer and use it in GitHub Desktop.
<?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