protected function UnserializationTest::createCdfDocumentFromFixture in Acquia Content Hub 8.2
Creates CDF document from fixture.
Parameters
string $fixture_filename: Fixture file name.
Return value
\Acquia\ContentHubClient\CDFDocument CDF document.
Throws
\ReflectionException
File
- tests/
src/ Kernel/ UnserializationTest.php, line 211
Class
- UnserializationTest
- Tests that entities are properly unserialized.
Namespace
Drupal\Tests\acquia_contenthub\KernelCode
protected function createCdfDocumentFromFixture($fixture_filename) : CDFDocument {
$version_directory = $this
->getDrupalVersion();
$path_to_fixture = sprintf("%s/tests/fixtures/import/{$version_directory}/%s", drupal_get_path('module', 'acquia_contenthub'), $fixture_filename);
$json = file_get_contents($path_to_fixture);
$data = Json::decode($json);
$document_parts = [];
foreach ($data['entities'] as $entity) {
$document_parts[] = $this
->populateCdfObject($entity);
}
$cdf_document = new CDFDocument(...$document_parts);
return $cdf_document;
}