function ContentImportTest::setUp

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

Overrides BrowserTestBase::setUp

File

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

Class

ContentImportTest
@covers \Drupal\Core\DefaultContent\Importer @group DefaultContent @group Recipe

Namespace

Drupal\FunctionalTests\DefaultContent

Code

protected function setUp() : void {
    parent::setUp();
    $this->setUpCurrentUser(admin: TRUE);
    BlockContentType::create([
        'id' => 'basic',
        'label' => 'Basic',
    ])->save();
    block_content_add_body_field('basic');
    $this->createVocabulary([
        'vid' => 'tags',
    ]);
    $this->createMediaType('image', [
        'id' => 'image',
    ]);
    $this->drupalCreateContentType([
        'type' => 'page',
    ]);
    $this->drupalCreateContentType([
        'type' => 'article',
    ]);
    $this->createEntityReferenceField('node', 'article', 'field_tags', 'Tags', 'taxonomy_term');
    // Create a field with custom serialization, so we can ensure that the
    // importer handles that properly.
    $field_storage = FieldStorageConfig::create([
        'entity_type' => 'taxonomy_term',
        'field_name' => 'field_serialized_stuff',
        'type' => 'serialized_property_item_test',
    ]);
    $field_storage->save();
    FieldConfig::create([
        'field_storage' => $field_storage,
        'bundle' => 'tags',
    ])->save();
    ConfigurableLanguage::createFromLangcode('fr')->save();
    ContentLanguageSettings::create([
        'target_entity_type_id' => 'node',
        'target_bundle' => 'article',
    ])->setThirdPartySetting('content_translation', 'enabled', TRUE)
        ->save();
    $this->contentDir = $this->getDrupalRoot() . '/core/tests/fixtures/default_content';
    \Drupal::service('file_system')->copy($this->contentDir . '/file/druplicon_copy.png', $this->publicFilesDirectory . '/druplicon_copy.png', FileExists::Error);
}

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