public function ExporterIntegrationTest::testModuleExport in Default Content for D8 8
Same name and namespace in other branches
- 2.0.x tests/src/Kernel/ExporterIntegrationTest.php \Drupal\Tests\default_content\Kernel\ExporterIntegrationTest::testModuleExport()
Tests exportModuleContent().
File
- tests/
src/ Kernel/ ExporterIntegrationTest.php, line 164
Class
- ExporterIntegrationTest
- Tests export functionality.
Namespace
Drupal\Tests\default_content\KernelCode
public function testModuleExport() {
\Drupal::service('module_installer')
->install([
'node',
'default_content',
'default_content_export_test',
]);
\Drupal::service('router.builder')
->rebuild();
$this->exporter = \Drupal::service('default_content.exporter');
$test_uuid = '0e45d92f-1919-47cd-8b60-964a8a761292';
$node_type = NodeType::create([
'type' => 'test',
]);
$node_type
->save();
$node = Node::create([
'type' => $node_type
->id(),
'title' => 'test node',
]);
$node->uuid = $test_uuid;
$node
->save();
$node = Node::load($node
->id());
$serializer = \Drupal::service('serializer');
\Drupal::service('hal.link_manager')
->setLinkDomain($this->container
->getParameter('default_content.link_domain'));
$expected_node = $serializer
->serialize($node, 'hal_json', [
'json_encode_options' => JSON_PRETTY_PRINT,
]);
$content = $this->exporter
->exportModuleContent('default_content_export_test');
$this
->assertEqual($content['node'][$test_uuid], $expected_node);
}