File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 99use Astrotomic \Translatable \Tests \Eloquent \Person ;
1010use Astrotomic \Translatable \Tests \Eloquent \Vegetable ;
1111use Astrotomic \Translatable \Tests \Eloquent \VegetableTranslation ;
12+ use Exception ;
1213use Illuminate \Database \Eloquent \MassAssignmentException ;
1314use Illuminate \Foundation \Testing \RefreshDatabase ;
1415use Illuminate \Support \Facades \App ;
@@ -1044,4 +1045,21 @@ public function it_does_not_delete_on_cascade_after_retrieving_a_model()
10441045 $ this ->assertDatabaseMissing ('vegetables ' , ['identity ' => $ vegetable ->identity ]);
10451046 $ this ->assertDatabaseHas ('vegetable_translations ' , ['vegetable_identity ' => $ vegetable ->identity ]);
10461047 }
1048+
1049+ /** @test */
1050+ public function it_can_restore_translations_in_a_transaction ()
1051+ {
1052+ Vegetable::enableDeleteTranslationsCascade ();
1053+ $ vegetable = factory (Vegetable::class)->create (['name:en ' => 'Peas ' ]);
1054+
1055+ $ this ->assertDatabaseHas ('vegetables ' , ['identity ' => $ vegetable ->identity ]);
1056+ $ this ->assertDatabaseHas ('vegetable_translations ' , ['vegetable_identity ' => $ vegetable ->identity ]);
1057+
1058+ DB ::connection ()->beginTransaction ();
1059+ $ vegetable ->delete ();
1060+ DB ::connection ()->rollBack ();
1061+
1062+ $ this ->assertDatabaseHas ('vegetables ' , ['identity ' => $ vegetable ->identity ]);
1063+ $ this ->assertDatabaseHas ('vegetable_translations ' , ['vegetable_identity ' => $ vegetable ->identity ]);
1064+ }
10471065}
You can’t perform that action at this time.
0 commit comments