| @@ 16-36 (lines=21) @@ | ||
| 13 | * |
|
| 14 | * @return void |
|
| 15 | */ |
|
| 16 | public function run() |
|
| 17 | { |
|
| 18 | $video = Video::find(1); |
|
| 19 | $type = [ |
|
| 20 | 'like', |
|
| 21 | 'dislike', |
|
| 22 | ]; |
|
| 23 | ||
| 24 | for ($i = 0; $i < 100; $i++) { |
|
| 25 | $user = $this->createUser(); |
|
| 26 | $key = array_rand($type); |
|
| 27 | ||
| 28 | $data = [ |
|
| 29 | 'user_id' => $user->id, |
|
| 30 | 'video_id' => $video->id, |
|
| 31 | 'type' => $type[$key], |
|
| 32 | ]; |
|
| 33 | ||
| 34 | LikeDislike::create($data); |
|
| 35 | } |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Create fake user. |
|
| @@ 56-76 (lines=21) @@ | ||
| 53 | return $video; |
|
| 54 | } |
|
| 55 | ||
| 56 | private function createFakeLikes($video_id) |
|
| 57 | { |
|
| 58 | $video = Video::find($video_id); |
|
| 59 | $type = [ |
|
| 60 | 'like', |
|
| 61 | 'dislike', |
|
| 62 | ]; |
|
| 63 | ||
| 64 | for ($i = 0; $i < 10; $i++) { |
|
| 65 | $user = $this->createUser(); |
|
| 66 | $key = array_rand($type); |
|
| 67 | ||
| 68 | $data = [ |
|
| 69 | 'user_id' => $user->id, |
|
| 70 | 'video_id' => $video->id, |
|
| 71 | 'type' => $type[$key], |
|
| 72 | ]; |
|
| 73 | ||
| 74 | LikeDislike::create($data); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| 78 | /** |
|
| 79 | * Test likes in database are listed by API. |
|