create(); $this->actingAs($user); $response = $this->get(route('students.index')); $response->assertRedirect(route('dashboard')); actAsAdmin(); $response = $this->get(route('students.index')); $response->assertRedirect(route('dashboard')); }); it('redirects to the students index if the user has a school', function () { $user = User::factory()->create(); $school = School::factory()->create(); $user->school_id = $school->id; $user->save(); $this->actingAs($user); $response = $this->get(route('students.index')); $response->assertOk(); }); it('returns the view students.index', function () { $user = User::factory()->create(); $school = School::factory()->create(); $audition = Audition::factory()->create(); $student = Student::factory()->forSchool($school)->create(); $user->school_id = $school->id; $user->save(); $this->actingAs($user); $response = $this->get(route('students.index')); $response->assertViewIs('students.index') ->assertViewHas('students', function ($students) use ($student) { return $students->contains($student); }) ->assertViewHas('auditions', function ($auditions) use ($audition) { return $auditions->contains($audition); }) ->assertSee(route('students.store')); }); }); describe('Test the store method of the student controller', function () { });