Parent Issue / 親Issue
#550
Motivation / 目的
Implement the persistence layer for favorites as part of #550. The intermediate table migration is covered in #551 (Domain layer); this issue implements the Eloquent model and repository on top of it.
お気に入りAPIのInfra層(#550)として、リポジトリ実装を行います。中間テーブルのmigrationは #551(Domain層)で対応するため、本Issueでは Eloquentモデルとリポジトリの実装のみを行います。
What to do / 実施内容
Eloquent Model
Repository
FavoriteRepository implements FavoriteRepositoryInterface
add: 重複時は FavoriteAlreadyExistsException をスロー
remove: 対象が無ければ FavoriteNotFoundException をスロー
existsForUser
findHeritageIdsByUserId
Tests / テスト
実DB(heritage-mysql-test)を使ったインテグレーションテスト
test_add_creates_favorite_record
test_add_throws_exception_when_already_favorited
test_remove_deletes_favorite_record
test_remove_throws_exception_when_not_favorited
test_existsForUser_returns_true_when_favorited
test_existsForUser_returns_false_when_not_favorited
test_findHeritageIdsByUserId_returns_ids_in_order
Parent Issue / 親Issue
#550
Motivation / 目的
Implement the persistence layer for favorites as part of #550. The intermediate table migration is covered in #551 (Domain layer); this issue implements the Eloquent model and repository on top of it.
お気に入りAPIのInfra層(#550)として、リポジトリ実装を行います。中間テーブルのmigrationは #551(Domain層)で対応するため、本Issueでは Eloquentモデルとリポジトリの実装のみを行います。
What to do / 実施内容
Eloquent Model
FavoriteHeritageRepository
FavoriteRepository implements FavoriteRepositoryInterfaceadd: 重複時はFavoriteAlreadyExistsExceptionをスローremove: 対象が無ければFavoriteNotFoundExceptionをスローexistsForUserfindHeritageIdsByUserIdTests / テスト
実DB(heritage-mysql-test)を使ったインテグレーションテスト
test_add_creates_favorite_recordtest_add_throws_exception_when_already_favoritedtest_remove_deletes_favorite_recordtest_remove_throws_exception_when_not_favoritedtest_existsForUser_returns_true_when_favoritedtest_existsForUser_returns_false_when_not_favoritedtest_findHeritageIdsByUserId_returns_ids_in_order