protected function ExportTest::createNodeWithReference in Acquia Content Hub 8.2
Creates a node with an entity reference field.
Parameters
int $tid1: Id of a taxonomy term.
int $tid2: Id of a taxonomy term.
int $tid3: Id of a taxonomy term.
int $items_expected: Expected number of items in the queue.
array $cdf_expectations: The sets of expectation arguments for CDF object validation.
Return value
int Node id.
Throws
\Drupal\Core\Entity\EntityStorageException
See also
\Drupal\Tests\acquia_contenthub\Kernel\ExportTest::createFields()
\Drupal\Tests\acquia_contenthub\Kernel\ExportTest::createTaxonomyTerms()
2 calls to ExportTest::createNodeWithReference()
- ExportTest::testPublishing in tests/
src/ Kernel/ ExportTest.php - Tests Acquia ContentHub content/configuration export.
- ExportTest::testQueue in tests/
src/ Kernel/ ExportTest.php - Tests Acquia ContentHub export queue.
File
- tests/
src/ Kernel/ ExportTest.php, line 1071
Class
- ExportTest
- Tests entity exports.
Namespace
Drupal\Tests\acquia_contenthub\KernelCode
protected function createNodeWithReference($tid1, $tid2, $tid3, &$items_expected, array &$cdf_expectations = []) {
$title = $this
->getRandomGenerator()
->word(32);
$bundle = 'test_content_type';
$node = Node::create([
'type' => 'test_content_type',
'title' => $title,
'status' => Node::PUBLISHED,
'field_term_reference' => [
[
'target_id' => $tid1,
],
[
'target_id' => $tid2,
],
[
'target_id' => $tid3,
],
],
]);
$node
->save();
$items_expected = 1;
$field = [
'field_1' => [
'value' => [
'en' => [],
],
],
'field_term_reference' => [
'value' => [
'en' => $this->termUuids,
],
],
];
$field_metadata = [
'field_1' => [
'type' => 'string_long',
],
'field_term_reference' => [
'type' => 'entity_reference',
'target' => 'taxonomy_term',
],
];
$cdf_expectations = [
[
$node
->id(),
$title,
$bundle,
Node::PUBLISHED,
$field,
$field_metadata,
],
];
return $node
->id();
}