You are here

public function GroupContentCrudHookTest::testGroupedEntityDeletion in Group 8

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

Tests that a grouped entity deletion triggers group content deletion.

File

tests/src/Kernel/GroupContentCrudHookTest.php, line 25

Class

GroupContentCrudHookTest
Tests the way group content entities react to entity CRUD events.

Namespace

Drupal\Tests\group\Kernel

Code

public function testGroupedEntityDeletion() {
  $account = $this
    ->createUser();
  $group = $this
    ->createGroup([
    'uid' => $account
      ->id(),
  ]);
  $count = count($group
    ->getContent());
  $account
    ->delete();
  $this
    ->assertCount($count - 1, $group
    ->getContent(), "Deleting the group owner's account reduces the group content count by one.");
}