@key what if you try checking assertStatus() code first before checking assertsee()?
And in your action, you try this way-
$videos = Video::paginate()->get();
instead of -
$videos = Video::paginate()->get(10);
This is my test.
/** @test */
public function a_user_can_post_a_video() {
//$this->withoutExceptionHandling();
$this->actingAs(factory('App\User')->create());
$attributes = [
'title' => $this->faker->sentence,
'description' => $this->faker->paragraph,
'video_url' => $this->faker->url
];
$this->post('/videos', $attributes)->assertRedirect('/videos');
$this->assertDatabaseHas('videos', $attributes);
$this->get('/videos')->assertSee($attributes['title']);
}
This was in my VideosController by mistake. Instead of using Video::paginate(10), i used Video::paginate()->get(10).
public function index()
{
$videos = Video::paginate()->get(10);
return view('videos.index', compact('videos'));
}
The problem is that when i run test, all 4 assertions are green but of-course there is an Invalid argument supplied error in browser.
My question is why its passing $this->get('/videos')->assertSee($attributes['title']); assertion.
Thanks
i'm still wondering why assertSee() is passing while there is no title available on error page
When you do something like $this->get('/videos') in a feature test, it will return an Illuminate\Testing\TestResponse instance. It is the TestResponse instance that your assertion checks against and not the page you see in the browser.
So, if your video was returned, it will be in the TestResponse object even if some other error is preventing it from being shown on the page.
Please or to participate in this conversation.