Domain\Classroom\ClassroomRepositoryTest::test_associate_students PHP Method

test_associate_students() public method

Test associate students.
    public function test_associate_students()
    {
        $classroom = factory(Classroom::class)->create();
        $students = factory(Student::class, 30)->create();
        $data = ['id' => $classroom->id, 'students' => []];
        $random = $students->random(3)->each(function ($student) use(&$data) {
            $data['students'][] = ['id' => $student->id];
        });
        $repo = App::make(ClassroomRepository::class);
        $repo->associateStudents($classroom, $data);
        foreach ($data['students'] as $key => $value) {
            $this->seeInDatabase('classroom_student', ['classroom_id' => $classroom->id, 'student_id' => $data['students'][$key]['id']]);
        }
    }