private function ContentHubEntityExportControllerTest::createContentHubEntity in Acquia Content Hub 8
Creates a Content Hub Entity for testing purposes.
Parameters
array $values: An array of values.
Return value
\Acquia\ContentHubClient\Entity A Content Hub Entity fully loaded.
Throws
\Exception
1 call to ContentHubEntityExportControllerTest::createContentHubEntity()
- ContentHubEntityExportControllerTest::testTrackExportedEntity in tests/
src/ Unit/ Controller/ ContentHubEntityExportControllerTest.php - Tests trackExportedEntity method.
File
- tests/
src/ Unit/ Controller/ ContentHubEntityExportControllerTest.php, line 576
Class
- ContentHubEntityExportControllerTest
- Unit test for ContentHubEntityExportController class.
Namespace
Drupal\Tests\acquia_contenthub\Unit\ControllerCode
private function createContentHubEntity(array $values = []) {
// Defining a default entity.
$default_entities = $this
->getEntities();
$values = $values + $default_entities['entities'][0];
// Creating a Content Hub Entity.
$entity = new Entity();
$entity
->setUuid($values['uuid']);
$entity
->setType($values['type']);
$entity
->setOrigin($values['origin']);
$entity
->setCreated($values['created']);
$entity
->setModified($values['modified']);
// Adding Attributes.
foreach ($values['attributes'] as $name => $attr) {
$attribute = new Attribute($attr['type']);
$attribute
->setValues($attr['value']);
$entity
->setAttribute($name, $attribute);
}
return $entity;
}