我有以下测试...
<?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');
});
}
}
我得到的错误是
1) Tests\Feature\VisitGameworldTest::test_can_visit_gameworld
ErrorException: Undefined variable: gameworld
当我做 dd($gameworld) 时,我得到了我期望的结果。
有人可以告诉我这里出了什么问题吗?
谢谢。