Does the factory work as expected? What do you see if you dd $gameworld?
$gameworld = factory(Gameworld::class)->create([
'name' => 'DS Test 1'
]);
dd($gameworld);
Hi there - I have the following test created..
public function test_can_search_and_find_a_gameworld()
{
$gameworld = factory(Gameworld::class)->create([
'name' => 'DS Test 1'
]);
$this->visit('/game/search') // pass
->see('Search For Game') // pass
->type('DS', '#gameworld_name') // pass
->press('Search') // pass
->seePageIs('/game/search') // pass
->see('Game Search Results') // pass
->see('DS Test 1'); // fails - no data is making it to the view...
}
What I am trying to prove is that I can search for a game, and see it come back in the view. The test fails, but when I actually do this action in the web site by hand, it passes. Now, some would say, why persist with a test if the actual functionality is in place, but I want my test to work! I suspect because I am not "redirecting" to the /game/search url with the data. Somehow it is falling off and not making it to the the view.
My view looks like this:
@section('content')
<h1>Game Search Results</h1>
<table class='table'>
<tr>
<th>ID</th>
<th>Name</th>
<th>League</th>
<th>Start Date</th>
<th>Owner</th>
<th></th>
</tr>
@if(empty($gameworld))
empty.
@else
<tr>
<td>$gameworld->id</td>
<td>$gameworld->name</td>
</tr>
@endif
</table>
@endsection
If I was to change my last assertion to
->see('empty');
then my test passes.
My question is ultimately - is there a way to test with data sent to the view? Thanks in advance.
Please or to participate in this conversation.