protected function FieldTranslationSqlStorageTest::assertFieldStorageLangcode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php \Drupal\system\Tests\Entity\FieldTranslationSqlStorageTest::assertFieldStorageLangcode()
Checks whether field languages are correctly stored for the given entity.
Parameters
\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity fields are attached to.
string $message: (optional) A message to display with the assertion.
1 call to FieldTranslationSqlStorageTest::assertFieldStorageLangcode()
- FieldTranslationSqlStorageTest::testFieldSqlStorage in core/
modules/ system/ src/ Tests/ Entity/ FieldTranslationSqlStorageTest.php - Tests field SQL storage.
File
- core/
modules/ system/ src/ Tests/ Entity/ FieldTranslationSqlStorageTest.php, line 79 - Contains \Drupal\system\Tests\Entity\FieldTranslationSqlStorageTest.
Class
- FieldTranslationSqlStorageTest
- Tests Field translation SQL Storage.
Namespace
Drupal\system\Tests\EntityCode
protected function assertFieldStorageLangcode(FieldableEntityInterface $entity, $message = '') {
$status = TRUE;
$entity_type = $entity
->getEntityTypeId();
$id = $entity
->id();
$langcode = $entity
->getUntranslated()
->language()
->getId();
$fields = array(
$this->fieldName,
$this->untranslatableFieldName,
);
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping = \Drupal::entityManager()
->getStorage($entity_type)
->getTableMapping();
foreach ($fields as $field_name) {
$field_storage = FieldStorageConfig::loadByName($entity_type, $field_name);
$table = $table_mapping
->getDedicatedDataTableName($field_storage);
$record = \Drupal::database()
->select($table, 'f')
->fields('f')
->condition('f.entity_id', $id)
->condition('f.revision_id', $id)
->execute()
->fetchObject();
if ($record->langcode != $langcode) {
$status = FALSE;
break;
}
}
return $this
->assertTrue($status, $message);
}