function ContentImportTest::testDirectContentImportWithDifferentUser

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/FunctionalTests/DefaultContent/ContentImportTest.php \Drupal\FunctionalTests\DefaultContent\ContentImportTest::testDirectContentImportWithDifferentUser()

Tests importing content directly, via the API, with a different user.

File

core/tests/Drupal/FunctionalTests/DefaultContent/ContentImportTest.php, line 140

Class

ContentImportTest
Tests Content Import.

Namespace

Drupal\FunctionalTests\DefaultContent

Code

public function testDirectContentImportWithDifferentUser() : void {
  // During import, Content Moderation will assume that new moderated entities
  // are in the default workflow state, and the user will need permission to
  // change its state. This isn't really relevant to this test, since in
  // practice, importing requires administrative privileges anyway.
  $user = $this->createUser([
    'use editorial transition publish',
    'use editorial transition create_new_draft',
  ]);
  $importer = $this->container
    ->get(Importer::class);
  $importer->importContent(new Finder($this->contentDir), account: $user);
  $this->assertContentWasImported($user);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.