@@ -646,6 +646,42 @@ public function testAllPermissionsScopedOnTeams()
646646
647647 }
648648
649+ public function testManyToManyRecordsAreRemoved ()
650+ {
651+ /*
652+ |------------------------------------------------------------
653+ | Set
654+ |------------------------------------------------------------
655+ */
656+ $ roleA = Role::create (['name ' => 'role_a ' ]);
657+ $ permissionA = Permission::create (['name ' => 'permission_a ' ]);
658+
659+ $ teamA = Team::create (['name ' => 'team_a ' ]);
660+
661+ $ this ->user ->addRole ($ roleA , $ teamA );
662+ $ this ->user ->givePermission ($ permissionA );
663+
664+ // force-deleting because the user model has soft-deletes enabled
665+ $ this ->user ->forceDelete ();
666+
667+ /*
668+ |------------------------------------------------------------
669+ | Assertion
670+ |------------------------------------------------------------
671+ */
672+ $ this ->assertModelMissing ($ this ->user );
673+
674+ $ this ->assertDatabaseMissing (
675+ $ this ->app ['config ' ]->get ('laratrust.tables.role_user ' ),
676+ ['user_id ' => $ this ->user ->id ]
677+ );
678+
679+ $ this ->assertDatabaseMissing (
680+ $ this ->app ['config ' ]->get ('laratrust.tables.permission_user ' ),
681+ ['user_id ' => $ this ->user ->id ]
682+ );
683+ }
684+
649685 protected function assertWasAttached ($ objectName , $ result )
650686 {
651687 $ relationship = \Illuminate \Support \Str::plural ($ objectName );
0 commit comments