function ContentExportTest::testCircularDependency
Tests that the exporter handles circular dependencies gracefully.
File
-
core/
tests/ Drupal/ FunctionalTests/ DefaultContent/ ContentExportTest.php, line 260
Class
- ContentExportTest
- Tests exporting content in YAML format.
Namespace
Drupal\FunctionalTests\DefaultContentCode
public function testCircularDependency() : void {
$this->createEntityReferenceField('node', 'article', 'field_related', 'Related Content', 'node', selection_handler_settings: [
'target_bundles' => [
'page' => 'page',
],
]);
$this->createEntityReferenceField('node', 'page', 'field_related', 'Related Content', 'node', selection_handler_settings: [
'target_bundles' => [
'article' => 'article',
],
]);
$page = $this->drupalCreateNode([
'type' => 'page',
]);
$article = $this->drupalCreateNode([
'type' => 'article',
'field_related' => $page,
]);
$page->set('field_related', $article)
->save();
$command = [
'content:export',
'node',
$page->id(),
'--with-dependencies',
'--dir=public://content',
];
// If the export takes more than 10 seconds, it's probably stuck in an
// infinite loop.
$process = $this->runDrupalCommand($command, 10);
$this->assertSame(0, $process->wait());
$destination = 'public://content/node';
$this->assertFileExists($destination . '/' . $page->uuid() . '.yml');
$this->assertFileExists($destination . '/' . $article->uuid() . '.yml');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.