Domain\Matter\Http\MatterControllerTest::test_associate_lessons PHP Method

test_associate_lessons() public method

Test associate lessons.
    public function test_associate_lessons()
    {
        $matter = factory(Matter::class)->create();
        $lessons = factory(Lesson::class, 30)->create();
        $data = ['id' => $matter->id, 'lessons' => []];
        $random = $lessons->random(3)->each(function ($matter) use(&$data) {
            $data['lessons'][] = ['id' => $matter->id];
        });
        $this->put('api/v1/matter/' . $matter->id . '/lessons', $data);
        $this->seeStatusCode(200);
        $this->seeJson(['status' => 'ok']);
        foreach ($data['lessons'] as $key => $value) {
            $this->seeInDatabase('matter_lesson', ['matter_id' => $matter->id, 'lesson_id' => $data['lessons'][$key]['id']]);
        }
    }