assertSee returning green when it shouldn't
I am following this series https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/3
The issue I'm having is that tests are returning green when they should have failed. The method is the same as Jeff is using (together with a setUp()), and DB for phpunit is in-memory sqlite:
public function a_user_can_read_replies_that_are_associated_with_thread()
{
$reply = factory(Reply::class)->create(['thread_id' => $this->thread->id]);
$this->get('/threads/' . $this->thread->id)
->assertSee($reply->body);
}
This should fail as the view is using foreach on a non existing relationship @foreach ($thread->replies as $reply).
Clearly enough, when I visit the following URL locally it throws an error, but tests pass.
If I change the test to instead use assertStatus(200) it fails because it throws 500 instead.
I tried dumping the $reply within test itself and it is generated fine.
Is the method itself flawed or am I doing something wrong?
EDIT: Laravel version 6.2, phpunit 8.0
If you check my previous response
Then I would go with what @nakov suggested. Always use assertOK() or assertStatus() calls. It is a nice habit that I also use. Just think of it as when you call once() or times() with mocks. And it makes your app that more tested.
Please or to participate in this conversation.