0
私は次のテストを持っている...私が取得私のlaravel duskテストが未定義の変数で失敗するのはなぜですか?
<?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)を行うと、私は私が期待した結果を得ることです。
ここで間違っていることを誰かに教えてもらえますか?
ありがとうございました。
だあなたは変数について、それを伝える必要がありますので、別のスコープです。おそらく 'use'キーワードが必要です。 http://php.net/manual/en/functions.anonymous.php –
を参照してください。もちろんするよ。どうもありがとう。 – dstewart101