You are here

public function GroupContentStorageTest::testCreateForUnsavedGroup in Group 8

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

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

@covers ::createForEntityInGroup

File

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

Class

GroupContentStorageTest
Tests the behavior of group content storage handler.

Namespace

Drupal\Tests\group\Kernel

Code

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