function ContentExportTest::testExportSingleEntityToDirectory

Tests exporting a single entity to a directory with attachments.

File

core/tests/Drupal/FunctionalTests/DefaultContent/ContentExportTest.php, line 188

Class

ContentExportTest
Tests exporting content in YAML format.

Namespace

Drupal\FunctionalTests\DefaultContent

Code

public function testExportSingleEntityToDirectory() : void {
  $file = $this->container
    ->get(EntityRepositoryInterface::class)
    ->loadEntityByUuid('file', '7fb09f9f-ba5f-4db4-82ed-aa5ccf7d425d');
  $this->assertInstanceOf(File::class, $file);
  $dir = 'public://export-content';
  $process = $this->runDrupalCommand([
    'content:export',
    'file',
    $file->id(),
    "--dir={$dir}",
  ]);
  $this->assertSame(0, $process->wait());
  $this->assertStringContainsString('The file "' . $file->label() . '" was exported to ', $process->getOutput());
  $this->assertFileExists($dir . '/file/' . $file->uuid() . '.yml');
  $this->assertFileExists($dir . '/file/' . $file->getFilename());
}

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