Domain\Classroom\ClassroomRepositoryTest::test_associate_matters PHP Method

test_associate_matters() public method

Test associate matters.
    public function test_associate_matters()
    {
        $classroom = factory(Classroom::class)->create();
        $matters = factory(Matter::class, 30)->create();
        $data = ['id' => $classroom->id, 'matters' => []];
        $random = $matters->random(3)->each(function ($matter) use(&$data) {
            $data['matters'][] = ['id' => $matter->id];
        });
        $repo = App::make(ClassroomRepository::class);
        $repo->associateMatters($classroom, $data);
        foreach ($data['matters'] as $key => $value) {
            $this->seeInDatabase('classroom_matter', ['classroom_id' => $classroom->id, 'matter_id' => $data['matters'][$key]['id']]);
        }
    }