protected function ExportTest::createNodes in Acquia Content Hub 8.2
Creates node samples.
Parameters
int $items_expected: Expected number of items in the queue.
array $cdf_expectations: The sets of expectation arguments for CDF object validation.
array $uids: Optional list of author ids.
Return value
array List on node ids.
Throws
\Drupal\Core\Entity\EntityStorageException
4 calls to ExportTest::createNodes()
- ExportTest::testDelete in tests/
src/ Kernel/ ExportTest.php - Tests deleting content.
- ExportTest::testPublishing in tests/
src/ Kernel/ ExportTest.php - Tests Acquia ContentHub content/configuration export.
- ExportTest::testPublishingUserProfile in tests/
src/ Kernel/ ExportTest.php - Tests publishing of node and user profile.
- ExportTest::testQueue in tests/
src/ Kernel/ ExportTest.php - Tests Acquia ContentHub export queue.
File
- tests/
src/ Kernel/ ExportTest.php, line 655
Class
- ExportTest
- Tests entity exports.
Namespace
Drupal\Tests\acquia_contenthub\KernelCode
protected function createNodes(&$items_expected, array &$cdf_expectations = [], array $uids = []) {
$uid = array_shift($uids);
$bundle = 'test_content_type';
$title1 = $this
->getRandomGenerator()
->word(15);
$values = [
'title' => $title1,
'type' => $bundle,
'status' => Node::PUBLISHED,
'uid' => $uid ? $uid : 0,
];
$node1 = Node::create($values);
$node1
->save();
$uid = array_shift($uids);
$title2 = $this
->getRandomGenerator()
->word(15);
$values = [
'title' => $title2,
'type' => $bundle,
'status' => Node::NOT_PUBLISHED,
'uid' => $uid ? $uid : 0,
];
$node2 = Node::create($values);
$node2
->save();
$items_expected = 1;
$cdf_expectations = [
[
$node1
->id(),
$title1,
$bundle,
Node::PUBLISHED,
],
[
$node2
->id(),
$title2,
$bundle,
Node::NOT_PUBLISHED,
],
];
return [
$node1
->id(),
$node2
->id(),
];
}