Domain\Student\StudentRepositoryTest::test_get_with_classrooms_with_matters PHP Method

test_get_with_classrooms_with_matters() public method

    public function test_get_with_classrooms_with_matters()
    {
        $student = factory(Student::class)->create();
        $matters = factory(Matter::class, 40)->create();
        $classrooms = factory(Classroom::class, 10)->create();
        $classrooms->each(function ($classroom) use($student, $matters) {
            $student->classrooms()->attach($classroom);
            $matters->random(rand(3, 5))->each(function ($matter) use($classroom) {
                $classroom->matters()->attach($matter);
            });
        });
        $repo = App::make(StudentRepository::class);
        $student = $repo->getWithClassroomsAndMatters($student->id);
        foreach ($student->classrooms as $classroom) {
            $this->assertInstanceOf(Classroom::class, $classroom);
            foreach ($classroom->matters as $matter) {
                $this->assertInstanceOf(Matter::class, $matter);
            }
        }
    }