private function PublishOnlyRenderedTest::assertContainsOnlyRequiredCdfs in Acquia Lift Connector 8.4
Asserts that the pruned CDF document only contains the required entities.
Parameters
object $cdf_mock: The CDF test object to run the assertions against.
1 call to PublishOnlyRenderedTest::assertContainsOnlyRequiredCdfs()
- PublishOnlyRenderedTest::testOnPrunePublishCdfEntities in modules/
acquia_lift_publisher/ tests/ src/ Kernel/ EventSubscriber/ Publish/ PublishOnlyRenderedTest.php - @covers ::onPrunePublishCdfEntities
File
- modules/
acquia_lift_publisher/ tests/ src/ Kernel/ EventSubscriber/ Publish/ PublishOnlyRenderedTest.php, line 222
Class
- PublishOnlyRenderedTest
- Class PublishOnlyRenderedTest.
Namespace
Drupal\Tests\acquia_lift_publisher\Kernel\EventSubscriber\PublishCode
private function assertContainsOnlyRequiredCdfs(\stdClass $cdf_mock) {
$orig_rendered_entity1 = $cdf_mock->rendered_entities[0]
->getUuid();
$orig_rendered_entity2 = $cdf_mock->rendered_entities[1]
->getUuid();
$pruned = $cdf_mock->pruned;
$this
->addToAssertionCount(1);
if (!isset($pruned[$orig_rendered_entity1], $pruned[$orig_rendered_entity2])) {
throw new AssertionFailedError('CDF document contains the rendered entities');
}
$expected = $cdf_mock->expected;
$sorter = function (CDFObject $cdf1, CDFObject $cdf2) {
return $cdf1
->getUuid() <=> $cdf2
->getUuid();
};
usort($expected, $sorter);
usort($pruned, $sorter);
$this
->assertEquals($expected, array_values($pruned), 'The CDF document contains only the rendered entities, its source entity and the source entity tags.');
}