public function testDeleteFavorite() { $course_id = Course::all()->pluck('id')->random(); $this->repository->addFavorite($course_id); // $this->assertEquals( $course_id , $this->user->courses[0]->id ); $this->repository->deleteFavorite($course_id); $this->assertEmpty($this->user->courses); }
public function pinCourse($course_id, $status) { // pin $checkCourse = $this->favoriteRepository->checkCoursePined($course_id); if ($status == 1) { if (!$checkCourse) { $this->favoriteRepository->addFavorite($course_id); return true; } else { return false; } } else { if ($checkCourse) { $this->favoriteRepository->deleteFavorite($course_id); return true; } else { return false; } } }