You are here

public function GroupContentStorageTest::testCreateForUnsavedEntity in Group 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Kernel/GroupContentStorageTest.php \Drupal\Tests\group\Kernel\GroupContentStorageTest::testCreateForUnsavedEntity()

Tests the creation of a GroupContent entity using an unsaved entity.

@covers ::createForEntityInGroup

File

tests/src/Kernel/GroupContentStorageTest.php, line 96

Class

GroupContentStorageTest
Tests the behavior of group content storage handler.

Namespace

Drupal\Tests\group\Kernel

Code

public function testCreateForUnsavedEntity() {
  $group = $this
    ->createGroup();
  $account = $this
    ->createUnsavedUser();
  $this
    ->expectException(EntityStorageException::class);
  $this
    ->expectExceptionMessage('Cannot add an unsaved entity to a group.');
  $this->storage
    ->createForEntityInGroup($account, $group, 'user_as_content');
}