File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 33namespace Codeception \Module ;
44
55use Codeception \Module ;
6+ use Drupal \Core \Config \StorageInterface ;
7+ use Drupal \Core \Entity \EntityStorageInterface ;
68use Drupal \user \Entity \User ;
79use Faker \Factory ;
810use Codeception \Util \Drush ;
@@ -158,7 +160,7 @@ public function logInAs($username) {
158160 public function logInWithRole ($ role ) {
159161 $ user = $ this ->createUserWithRoles ([$ role ], Factory::create ()->password (12 , 14 ));
160162
161- $ this ->logInAs ($ user ->getUsername ());
163+ $ this ->logInAs ($ user ->getAccountName ());
162164
163165 return $ user ;
164166 }
@@ -198,14 +200,21 @@ private function deleteUsersContent($uid) {
198200 continue ;
199201 }
200202 try {
203+ /** @var EntityStorageInterface $storage */
201204 $ storage = \Drupal::entityTypeManager ()->getStorage ($ cleanup_entity );
202205 }
203206 catch (\Exception $ e ) {
204207 $ errors [] = 'Could not load storage ' . $ cleanup_entity ;
205208 continue ;
206209 }
207210 try {
208- $ entities = $ storage ->loadByProperties (['uid ' => $ uid ]);
211+ $ bundles = \Drupal::service ('entity_type.bundle.info ' )->getBundleInfo ($ cleanup_entity );
212+ foreach ($ bundles as $ bundle ) {
213+ $ all_bundle_fields = \Drupal::service ('entity_field.manager ' )->getFieldDefinitions ($ cleanup_entity , $ bundle );
214+ if (isset ($ all_bundle_fields ['uid ' ])) {
215+ $ entities = $ storage ->loadByProperties (['uid ' => $ uid ]);
216+ }
217+ }
209218 }
210219 catch (\Exception $ e ) {
211220 $ errors [] = 'Could not load entities of type ' . $ cleanup_entity . ' by uid ' . $ uid ;
You can’t perform that action at this time.
0 commit comments