I have the following test...
<?php
namespace Tests\Feature;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use App\Gameworld;
use Carbon\Carbon;
class VisitGameworldTest extends DuskTestCase
{
use DatabaseMigrations;
public function test_can_visit_gameworld()
{
// arrange
$gameworld = Gameworld::create([
'name' => 'LMS Main Game',
'start_date' => Carbon::parse('September 6th, 2017'),
'league' => 'Premier League',
]);
//dd($gameworld->id);
$this->browse(function (Browser $browser) {
$browser->visit('gameworld/'.$gameworld->id)
->assertSee('LMS Main Game')
->assertSee('September 6th, 2017')
->assertSee('Premier League');
});
}
}
The error I get is
1) Tests\Feature\VisitGameworldTest::test_can_visit_gameworld
ErrorException: Undefined variable: gameworld
When I do dd($gameworld) I get the result I expect.
Can someone tell me what has gone wrong here?
Thanks.