manshu's avatar
Level 28

Weird PHP Testing Changes with Laravel 5.6.3

How's this test passing, when my index method /course has nothing inside it.

    /** @test */
    public function to_see_all_courses()
    {
        $courses = factory(Course::class, 2)->create();
        $this->get('course');
        $this->assertCount(2, $courses);
    }
0 likes
2 replies
ejdelmonico's avatar

If you are trying to see courses on the /courses page the I would test first that you could see them and then check the number requested for pagination. Something like:

$course = factory(Course::class, 1)->create();
$this->get('/course');
$this->assertSee('$course->title');
manshu's avatar
Level 28

When i tried to use that, it gives me this error.

Error: Call to undefined method CreateCourseTest::assertSee()

Please or to participate in this conversation.