File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ trait HasLikes
1111 protected static function bootHasLikes ()
1212 {
1313 static ::deleting (function ($ model ) {
14- $ model ->likes -> each ->delete ();
14+ $ model ->likes () ->delete ();
1515 });
1616 }
1717
Original file line number Diff line number Diff line change 33namespace Tests \Components \Jobs ;
44
55use App \Jobs \DeleteThread ;
6+ use App \Models \Like ;
67use App \Models \Reply ;
78use App \Models \Thread ;
89use Illuminate \Foundation \Testing \DatabaseMigrations ;
@@ -17,11 +18,14 @@ public function we_can_delete_a_thread_and_its_replies()
1718 {
1819 $ thread = factory (Thread::class)->create ();
1920 $ reply = factory (Reply::class)->create (['replyable_id ' => $ thread ->id ()]);
21+ factory (Like::class)->states ('thread ' )->create (['likeable_id ' => $ thread ->id ()]);
22+ factory (Like::class)->states ('reply ' )->create (['likeable_id ' => $ reply ->id ()]);
2023
2124 $ this ->dispatch (new DeleteThread ($ thread ));
22-
25+
2326 $ this ->assertDatabaseMissing ('threads ' , ['id ' => $ thread ->id ()]);
2427 $ this ->assertDatabaseMissing ('replies ' , ['replyable_id ' => $ thread ->id ()]);
25- $ this ->assertDatabaseMissing ('likes ' , ['liked_type ' => get_class ($ reply ), 'liked_id ' => $ reply ->id ()]);
28+ $ this ->assertDatabaseMissing ('likes ' , ['likeable_type ' => 'threads ' , 'likeable_id ' => $ thread ->id ()]);
29+ $ this ->assertDatabaseMissing ('likes ' , ['likeable_type ' => 'replies ' , 'likeable_id ' => $ reply ->id ()]);
2630 }
2731}
You can’t perform that action at this time.
0 commit comments