diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php index 70a142a..e73fa90 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php @@ -215,42 +215,41 @@ public function testReferencedEntitiesStringId() { * Tests all the possible ways to autocreate an entity via the API. */ function testAutocreateApi() { - /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $this->entityManager ->getStorage($this->entityType) ->create(array('name' => $this->randomString())); // Test content entity autocreation. - $this->assertUserAutocreate($entity, function(UserInterface $user) use ($entity) { + $this->assertUserAutocreate($entity, function(EntityInterface $entity, UserInterface $user) { $entity->set('user_id', $user); }); - $this->assertUserAutocreate($entity, function(UserInterface $user) use ($entity) { + $this->assertUserAutocreate($entity, function(EntityInterface $entity, UserInterface $user) { $entity->set('user_id', $user, FALSE); }); - $this->assertUserAutocreate($entity, function(UserInterface $user) use ($entity) { + $this->assertUserAutocreate($entity, function(EntityInterface $entity, UserInterface $user) { $entity->user_id->setValue($user); }); - $this->assertUserAutocreate($entity, function(UserInterface $user) use ($entity) { + $this->assertUserAutocreate($entity, function(EntityInterface $entity, UserInterface $user) { $entity->user_id = $user; }); - $this->assertUserAutocreate($entity, function(UserInterface $user) use ($entity) { + $this->assertUserAutocreate($entity, function(EntityInterface $entity, UserInterface $user) { $entity->user_id->entity = $user; }); // Test config entity autocreation. - $this->assertUserRoleAutocreate($entity, function(RoleInterface $role) use ($entity) { + $this->assertUserRoleAutocreate($entity, function(EntityInterface $entity, RoleInterface $role) { $entity->set('user_role', $role); }); - $this->assertUserRoleAutocreate($entity, function(RoleInterface $role) use ($entity) { + $this->assertUserRoleAutocreate($entity, function(EntityInterface $entity, RoleInterface $role) { $entity->set('user_role', $role, FALSE); }); - $this->assertUserRoleAutocreate($entity, function(RoleInterface $role) use ($entity) { + $this->assertUserRoleAutocreate($entity, function(EntityInterface $entity, RoleInterface $role) { $entity->user_role->setValue($role); }); - $this->assertUserRoleAutocreate($entity, function(RoleInterface $role) use ($entity) { + $this->assertUserRoleAutocreate($entity, function(EntityInterface $entity, RoleInterface $role) { $entity->user_role = $role; }); - $this->assertUserRoleAutocreate($entity, function(RoleInterface $role) use ($entity) { + $this->assertUserRoleAutocreate($entity, function(EntityInterface $entity, RoleInterface $role) { $entity->user_role->entity = $role; }); } @@ -270,11 +269,11 @@ protected function assertUserAutocreate(EntityInterface $entity, $setter_callbac $storage = $this->entityManager->getStorage('user'); $user_id = $this->generateRandomEntityId(); $user = $storage->create(array('uid' => $user_id, 'name' => $this->randomString())); - $setter_callback($user); + $setter_callback($entity, $user); $entity->save(); $storage->resetCache(); $user = User::load($user_id); - $this->assertEqual($entity->user_id->target_id, $user->id()); + return $this->assertEqual($entity->user_id->target_id, $user->id()); } /** @@ -292,11 +291,11 @@ protected function assertUserRoleAutocreate(EntityInterface $entity, $setter_cal $storage = $this->entityManager->getStorage('user_role'); $role_id = $this->generateRandomEntityId(TRUE); $role = $storage->create(array('id' => $role_id, 'label' => $this->randomString())); - $setter_callback($role); + $setter_callback($entity, $role); $entity->save(); $storage->resetCache(); $role = Role::load($role_id); - $this->assertEqual($entity->user_role->target_id, $role->id()); + return $this->assertEqual($entity->user_role->target_id, $role->id()); } }