public function RemoveRevisionFieldTest::testRemoveRevisionField in Acquia Content Hub 8.2
Tests the removal of ID and Revision field.
@covers ::excludeContentField
Throws
\Drupal\Core\Entity\EntityStorageException
File
- tests/
src/ Kernel/ EventSubscriber/ ExcludeContentField/ RemoveRevisionFieldTest.php, line 62
Class
- RemoveRevisionFieldTest
- Tests remove revision field serialization.
Namespace
Drupal\Tests\acquia_contenthub\Kernel\EventSubscriber\ExcludeContentFieldCode
public function testRemoveRevisionField() {
$this
->createContentType([
'type' => 'article',
'name' => 'article',
]);
$node = $this
->createNode([
'type' => 'article',
]);
$remove_id_and_revision_field = new RemoveRevisionField();
foreach ($node as $field_name => $field) {
$event = new ExcludeEntityFieldEvent($node, $field_name, $field);
$remove_id_and_revision_field
->excludeContentField($event);
if ($field_name === $event
->getEntity()
->getEntityType()
->getKey('revision')) {
$this
->assertTrue($event
->isExcluded());
$this
->assertTrue($event
->isPropagationStopped());
}
else {
$this
->assertFalse($event
->isExcluded());
$this
->assertFalse($event
->isPropagationStopped());
}
}
}