public function testUserSumRating()
 {
     Rating::unguard();
     $post1 = Post::find(1);
     $post2 = Post::find(2);
     $user1 = User::find(1);
     Rating::create(['id' => 5, 'rating' => 1, 'rateable_id' => $post1->id, 'rateable_type' => 'Post', 'user_id' => $user1->id]);
     Rating::create(['id' => 6, 'rating' => 1, 'rateable_id' => $post2->id, 'rateable_type' => 'Post', 'user_id' => $user1->id]);
     Rating::reguard();
     $this->assertEquals(6, Post::find(1)->userSumRating);
     $this->assertEquals(6, Post::find(1)->userSumRating());
     $this->assertEquals(2, Post::find(2)->userSumRating);
     $this->assertEquals(2, Post::find(2)->userSumRating());
 }
 public function run()
 {
     DB::table('ratings')->delete();
     Rating::unguard();
     $post1 = Post::find(1);
     $post2 = Post::find(2);
     $post3 = Post::find(3);
     $user1 = User::find(1);
     $user2 = User::find(2);
     Rating::create(['id' => 1, 'rating' => 5, 'rateable_id' => $post1->id, 'rateable_type' => 'Post', 'user_id' => $user1->id]);
     Rating::create(['id' => 2, 'rating' => 5, 'rateable_id' => $post1->id, 'rateable_type' => 'Post', 'user_id' => $user2->id]);
     Rating::create(['id' => 3, 'rating' => 1, 'rateable_id' => $post2->id, 'rateable_type' => 'Post', 'user_id' => $user1->id]);
     Rating::create(['id' => 4, 'rating' => 5, 'rateable_id' => $post2->id, 'rateable_type' => 'Post', 'user_id' => $user2->id]);
     Rating::reguard();
 }