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