You are here

private function FixtureBase::clearUserContent in Lightning Core 8.3

Same name and namespace in other branches
  1. 8.5 tests/src/FixtureBase.php \Drupal\Tests\lightning_core\FixtureBase::clearUserContent()
  2. 8.4 tests/src/FixtureBase.php \Drupal\Tests\lightning_core\FixtureBase::clearUserContent()

Deletes all content created by the current users.

1 call to FixtureBase::clearUserContent()
FixtureBase::tearDown in tests/src/FixtureBase.php
Tears down the fixture.

File

tests/src/FixtureBase.php, line 265

Class

FixtureBase
Base class for contexts which set up and tear down a complete test fixture.

Namespace

Drupal\Tests\lightning_core

Code

private function clearUserContent() {
  if (!$this->users) {
    return;
  }
  foreach ($this->trackedEntityTypes as $entity_type_id) {

    /** @var \Drupal\Core\Entity\EntityStorageInterface $storage */
    $storage = $this->container
      ->get('entity_type.manager')
      ->getStorage($entity_type_id);
    $entities = $storage
      ->loadByProperties([
      'uid' => $this->users,
    ]);
    $storage
      ->delete($entities);
  }
}