namespace Drupal\Tests\field\Kernel\String;
use Drupal\Component\Utility\Html;
-use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\entity_test\Entity\EntityTestRev;
*/
public static $modules = ['field', 'text', 'entity_test', 'system', 'filter', 'user'];
+ /**
+ * The entity type manager.
+ *
+ * @var \Drupal\Core\Entity\EntityTypeManagerInterface
+ */
+ protected $entityTypeManager;
+
/**
* @var string
*/
$this->entityType = 'entity_test_rev';
$this->bundle = $this->entityType;
- $this->fieldName = Unicode::strtolower($this->randomMachineName());
+ $this->fieldName = mb_strtolower($this->randomMachineName());
$field_storage = FieldStorageConfig::create([
'field_name' => $this->fieldName,
'settings' => [],
]);
$this->display->save();
+
+ $this->entityTypeManager = \Drupal::entityTypeManager();
}
/**
$value2 = $this->randomMachineName();
$entity->{$this->fieldName}->value = $value2;
$entity->save();
- $entity_new_revision = \Drupal::entityManager()->getStorage('entity_test_rev')->loadRevision($old_revision_id);
+ $entity_new_revision = $this->entityTypeManager->getStorage('entity_test_rev')->loadRevision($old_revision_id);
$this->renderEntityFields($entity, $this->display);
$this->assertLink($value2, 0);
$this->renderEntityFields($entity_new_revision, $this->display);
$this->assertLink($value, 0);
$this->assertLinkByHref('/entity_test_rev/' . $entity_new_revision->id() . '/revision/' . $entity_new_revision->getRevisionId() . '/view');
+
+ // Check that linking to a revisionable entity works if the entity type does
+ // not specify a 'revision' link template.
+ $entity_type = clone $this->entityTypeManager->getDefinition('entity_test_rev');
+ $link_templates = $entity_type->getLinkTemplates();
+ unset($link_templates['revision']);
+ $entity_type->set('links', $link_templates);
+ \Drupal::state()->set('entity_test_rev.entity_type', $entity_type);
+ $this->entityTypeManager->clearCachedDefinitions();
+
+ $this->renderEntityFields($entity_new_revision, $this->display);
+ $this->assertLink($value, 0);
+ $this->assertLinkByHref($entity->url('canonical'));
}
}