You are here

public function OgMembershipTest::testSetNonValidGroupException in Organic groups 8

Tests saving a membership with a non group entity.

@covers ::preSave

File

tests/src/Kernel/Entity/OgMembershipTest.php, line 284

Class

OgMembershipTest
Tests the OgMembership entity.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

public function testSetNonValidGroupException() {
  $non_group = EntityTest::create([
    'type' => mb_strtolower($this
      ->randomMachineName()),
    'name' => $this
      ->randomString(),
  ]);
  $non_group
    ->save();

  /** @var \Drupal\og\OgMembershipInterface $membership */
  $membership = Og::createMembership($non_group, $this->user);
  $this
    ->expectException(EntityStorageException::class);
  $membership
    ->save();
}