function ContentImportTest::setUp

Overrides BrowserTestBase::setUp

File

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

Class

ContentImportTest
@covers <a href="/api/drupal/core%21lib%21Drupal%21Core%21DefaultContent%21Importer.php/class/Importer/11.x" title="A service for handling import of content." class="local">\Drupal\Core\DefaultContent\Importer</a> @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.