setupUsers example

$this->referencingEntity->save();
  }

  /** * {@inheritdoc} */
  protected function setupUsers() {
    $this->entityOwner = $this->drupalCreateUser($this->getEntityOwnerPermissions(), 'entity_owner');
    $this->notEntityOwner = $this->drupalCreateUser();
    $this->notEntityOwner->set('roles', $this->entityOwner->getRoles(TRUE));
    $this->notEntityOwner->save();
    parent::setupUsers();
  }

  /** * Returns an array of permissions needed for the entity owner. */
  protected function getEntityOwnerPermissions() {
    return ['edit own entity_test content', 'translate editable entities', 'view test entity', 'view test entity translations', 'view unpublished test entity translations'];
  }

  /** * {@inheritdoc} */
protected $manager;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->setupLanguages();
    $this->setupBundle();
    $this->enableTranslation();
    $this->setupUsers();
    $this->setupTestFields();

    $this->manager = $this->container->get('content_translation.manager');
    $this->controller = $this->manager->getTranslationHandler($this->entityTypeId);

    // Rebuild the container so that the new languages are picked up by services     // that hold a list of languages.     $this->rebuildContainer();
  }

  /** * Adds additional languages. */
Home | Imprint | This part of the site doesn't use cookies.