public function OgMembershipTest::testSaveExistingMembership in Organic groups 8
Tests saving an existing membership.
@covers ::preSave
File
- tests/
src/ Kernel/ Entity/ OgMembershipTest.php, line 303
Class
- OgMembershipTest
- Tests the OgMembership entity.
Namespace
Drupal\Tests\og\Kernel\EntityCode
public function testSaveExistingMembership() {
$group = EntityTest::create([
'type' => mb_strtolower($this
->randomMachineName()),
'name' => $this
->randomString(),
]);
$group
->save();
$this->groupTypeManager
->addGroup('entity_test', $group
->bundle());
/** @var \Drupal\og\OgMembershipInterface $membership */
$membership1 = Og::createMembership($group, $this->user);
$membership1
->save();
$membership2 = Og::createMembership($group, $this->user);
$this
->expectException(EntityStorageException::class);
$membership2
->save();
}