View source
<?php
namespace Drupal\Tests\dynamic_entity_reference\Kernel;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\Tests\SchemaCheckTestTrait;
class DynamicEntityReferenceBaseFieldRevisionTest extends EntityKernelTestBase {
use SchemaCheckTestTrait;
protected $entityType = 'entity_test_rev';
protected $referencedEntityType = 'entity_test_mulrev';
protected $bundle = 'entity_test_rev';
protected $fieldName = 'dynamic_references';
protected static $modules = [
'dynamic_entity_reference',
];
public function testEntityReferenceNonRevisionableFieldValidation() {
\Drupal::state()
->set('dynamic_entity_reference_entity_test_entities', [
$this->entityType,
$this->referencedEntityType,
]);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_cardinality', 1);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_exclude', [
$this->entityType,
]);
$this
->enableModules([
'dynamic_entity_reference_entity_test',
]);
$this
->installEntitySchema($this->entityType);
$this
->installEntitySchema($this->referencedEntityType);
$entity_type_manager = \Drupal::entityTypeManager();
$referenced_entity = $entity_type_manager
->getStorage($this->referencedEntityType)
->create([
'type' => $this->bundle,
]);
$referenced_entity
->save();
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$entity->{$this->fieldName}->target_type = $referenced_entity
->getEntityTypeId();
$entity->{$this->fieldName}->target_id = $referenced_entity
->id();
$violations = $entity->{$this->fieldName}
->validate();
$this
->assertEquals($violations
->count(), 0, 'Validation passes.');
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$entity->{$this->fieldName}->entity = $referenced_entity;
$violations = $entity->{$this->fieldName}
->validate();
$this
->assertEquals($violations
->count(), 0, 'Validation passes.');
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$entity->{$this->fieldName}->target_type = $referenced_entity
->getEntityTypeId();
$entity->{$this->fieldName}->target_id = 9999;
$violations = $entity->{$this->fieldName}
->validate();
$this
->assertEquals($violations
->count(), 1, 'Validation throws a violation.');
$this
->assertEquals($violations[0]
->getMessage(), t('The referenced entity (%type: %id) does not exist.', [
'%type' => $this->referencedEntityType,
'%id' => 9999,
]));
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$entity->{$this->fieldName}->target_type = $entity
->getEntityTypeId();
$entity->{$this->fieldName}->target_id = $referenced_entity
->id();
$violations = $entity->{$this->fieldName}
->validate();
$this
->assertEquals($violations
->count(), 1, 'Validation throws a violation.');
$this
->assertEquals($violations[0]
->getMessage(), t('The referenced entity type (%type) is not allowed for this field.', [
'%type' => $entity
->getEntityTypeId(),
]));
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$entity->{$this->fieldName}->entity = $entity;
$violations = $entity->{$this->fieldName}
->validate();
$this
->assertEquals($violations
->count(), 1, 'Validation throws a violation.');
$this
->assertEquals($violations[0]
->getMessage(), t('The referenced entity type (%type) is not allowed for this field.', [
'%type' => $entity
->getEntityTypeId(),
]));
}
public function testNonRevisionableReferencedEntitiesMultipleLoad() {
\Drupal::state()
->set('dynamic_entity_reference_entity_test_entities', [
$this->entityType,
$this->referencedEntityType,
]);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_cardinality', FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_exclude', [
$this->entityType,
]);
$this
->enableModules([
'dynamic_entity_reference_entity_test',
]);
$this
->installEntitySchema($this->entityType);
$this
->installEntitySchema($this->referencedEntityType);
$entity_type_manager = \Drupal::entityTypeManager();
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$target_entities = [];
$reference_field = [];
for ($i = 0; $i < 3; $i++) {
$target_entity = $entity_type_manager
->getStorage($this->referencedEntityType)
->create([
'type' => $this->bundle,
]);
$target_entity
->save();
$target_entities[] = $target_entity;
$reference_field[] = [
'target_id' => $target_entity
->id(),
'target_type' => $this->referencedEntityType,
];
}
$reference_field[3]['target_id'] = 99999;
$reference_field[3]['target_type'] = $this->referencedEntityType;
$target_entities[3] = NULL;
$reference_field[4]['target_id'] = NULL;
$reference_field[4]['target_type'] = $this->referencedEntityType;
$target_entities[4] = NULL;
$reference_field[5]['target_id'] = 99999;
$reference_field[5]['target_type'] = $this->entityType;
$target_entities[5] = NULL;
$reference_field[6]['target_id'] = NULL;
$reference_field[6]['target_type'] = NULL;
$target_entities[6] = NULL;
$reference_field[7] = $reference_field[0];
$target_entities[7] = $target_entities[0];
$target_entity_unsaved = $entity_type_manager
->getStorage($this->referencedEntityType)
->create([
'type' => $this->bundle,
'name' => $this
->randomString(),
]);
$reference_field[8]['entity'] = $target_entity_unsaved;
$target_entities[8] = $target_entity_unsaved;
$entity->{$this->fieldName}
->setValue($reference_field);
$entities = $entity->{$this->fieldName}
->referencedEntities();
foreach ($target_entities as $delta => $target_entity) {
if (!empty($target_entity)) {
if (!$target_entity
->isNew()) {
$this
->assertEquals($target_entity
->id(), $entities[$delta]
->id());
}
else {
$this
->assertEquals($target_entity
->label(), $entities[$delta]
->label());
}
}
else {
$this
->assertFalse(isset($entities[$delta]));
}
}
}
public function testNonRevisionableMultipleEntityReference() {
\Drupal::state()
->set('dynamic_entity_reference_entity_test_entities', [
$this->entityType,
$this->referencedEntityType,
]);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_with_two_base_fields', TRUE);
$this
->enableModules([
'dynamic_entity_reference_entity_test',
]);
$this
->installEntitySchema($this->entityType);
$this
->installEntitySchema($this->referencedEntityType);
$referenced_entity = $this->container
->get('entity_type.manager')
->getStorage($this->entityType)
->create();
$referenced_entity
->save();
$referenced_entity_mul = $this->container
->get('entity_type.manager')
->getStorage($this->referencedEntityType)
->create();
$referenced_entity_mul
->save();
$entity = $this->container
->get('entity_type.manager')
->getStorage($this->entityType)
->create();
$entity->dynamic_references[] = $referenced_entity;
$entity->der[] = $referenced_entity_mul;
$entity
->save();
$entity = $this->container
->get('entity_type.manager')
->getStorage($this->entityType)
->loadUnchanged($entity
->id());
$this
->assertEquals($entity->dynamic_references[0]->target_id, $referenced_entity
->id());
$this
->assertEquals($entity->dynamic_references[0]->target_type, $referenced_entity
->getEntityTypeId());
$this
->assertEquals($entity->dynamic_references[0]->entity
->getName(), $referenced_entity
->getName());
$this
->assertEquals($entity->dynamic_references[0]->entity
->id(), $referenced_entity
->id());
$this
->assertEquals($entity->dynamic_references[0]->entity
->uuid(), $referenced_entity
->uuid());
$this
->assertEquals($entity->der[0]->target_id, $referenced_entity_mul
->id());
$this
->assertEquals($entity->der[0]->target_type, $referenced_entity_mul
->getEntityTypeId());
$this
->assertEquals($entity->der[0]->entity
->getName(), $referenced_entity_mul
->getName());
$this
->assertEquals($entity->der[0]->entity
->id(), $referenced_entity_mul
->id());
$this
->assertEquals($entity->der[0]->entity
->uuid(), $referenced_entity_mul
->uuid());
$database = $this->container
->get('database');
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_rev}')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_rev}')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_rev}')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_rev}')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_mulrev_property_data}')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_mulrev_property_data}')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_mulrev_property_data}')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_mulrev_property_data}')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$entity = $this->container
->get('entity_type.manager')
->getStorage($this->referencedEntityType)
->create();
$entity->der[] = $referenced_entity;
$entity->dynamic_references[] = $referenced_entity_mul;
$entity
->save();
$entity = $this->container
->get('entity_type.manager')
->getStorage($this->referencedEntityType)
->loadUnchanged($entity
->id());
$this
->assertEquals($entity->dynamic_references[0]->target_id, $referenced_entity_mul
->id());
$this
->assertEquals($entity->dynamic_references[0]->target_type, $referenced_entity_mul
->getEntityTypeId());
$this
->assertEquals($entity->dynamic_references[0]->entity
->getName(), $referenced_entity_mul
->getName());
$this
->assertEquals($entity->dynamic_references[0]->entity
->id(), $referenced_entity_mul
->id());
$this
->assertEquals($entity->dynamic_references[0]->entity
->uuid(), $referenced_entity_mul
->uuid());
$this
->assertEquals($entity->der[0]->target_id, $referenced_entity
->id());
$this
->assertEquals($entity->der[0]->target_type, $referenced_entity
->getEntityTypeId());
$this
->assertEquals($entity->der[0]->entity
->getName(), $referenced_entity
->getName());
$this
->assertEquals($entity->der[0]->entity
->id(), $referenced_entity
->id());
$this
->assertEquals($entity->der[0]->entity
->uuid(), $referenced_entity
->uuid());
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_rev}')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_rev}')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_rev}')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_rev}')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_mulrev_property_data}')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_mulrev_property_data}')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_mulrev_property_data}')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_mulrev_property_data}')
->fetchCol();
$this
->assertSame($int_column, $str_column);
}
public function testEntityReferenceRevisionableFieldValidation() {
\Drupal::state()
->set('dynamic_entity_reference_entity_test_entities', [
$this->entityType,
$this->referencedEntityType,
]);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_cardinality', 1);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_exclude', [
$this->entityType,
]);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_revisionable', TRUE);
$this
->enableModules([
'dynamic_entity_reference_entity_test',
]);
$this
->installEntitySchema($this->entityType);
$this
->installEntitySchema($this->referencedEntityType);
$entity_type_manager = \Drupal::entityTypeManager();
$referenced_entity = $entity_type_manager
->getStorage($this->referencedEntityType)
->create([
'type' => $this->bundle,
]);
$referenced_entity
->save();
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$entity->{$this->fieldName}->target_type = $referenced_entity
->getEntityTypeId();
$entity->{$this->fieldName}->target_id = $referenced_entity
->id();
$violations = $entity->{$this->fieldName}
->validate();
$this
->assertEquals($violations
->count(), 0, 'Validation passes.');
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$entity->{$this->fieldName}->entity = $referenced_entity;
$violations = $entity->{$this->fieldName}
->validate();
$this
->assertEquals($violations
->count(), 0, 'Validation passes.');
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$entity->{$this->fieldName}->target_type = $referenced_entity
->getEntityTypeId();
$entity->{$this->fieldName}->target_id = 9999;
$violations = $entity->{$this->fieldName}
->validate();
$this
->assertEquals($violations
->count(), 1, 'Validation throws a violation.');
$this
->assertEquals($violations[0]
->getMessage(), t('The referenced entity (%type: %id) does not exist.', [
'%type' => $this->referencedEntityType,
'%id' => 9999,
]));
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$entity->{$this->fieldName}->target_type = $entity
->getEntityTypeId();
$entity->{$this->fieldName}->target_id = $referenced_entity
->id();
$violations = $entity->{$this->fieldName}
->validate();
$this
->assertEquals($violations
->count(), 1, 'Validation throws a violation.');
$this
->assertEquals($violations[0]
->getMessage(), t('The referenced entity type (%type) is not allowed for this field.', [
'%type' => $entity
->getEntityTypeId(),
]));
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$entity->{$this->fieldName}->entity = $entity;
$violations = $entity->{$this->fieldName}
->validate();
$this
->assertEquals($violations
->count(), 1, 'Validation throws a violation.');
$this
->assertEquals($violations[0]
->getMessage(), t('The referenced entity type (%type) is not allowed for this field.', [
'%type' => $entity
->getEntityTypeId(),
]));
}
public function testRevisionableReferencedEntitiesMultipleLoad() {
\Drupal::state()
->set('dynamic_entity_reference_entity_test_entities', [
$this->entityType,
$this->referencedEntityType,
]);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_cardinality', FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_exclude', [
$this->entityType,
]);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_revisionable', TRUE);
$this
->enableModules([
'dynamic_entity_reference_entity_test',
]);
$this
->installEntitySchema($this->entityType);
$this
->installEntitySchema($this->referencedEntityType);
$entity_type_manager = \Drupal::entityTypeManager();
$entity = $entity_type_manager
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$target_entities = [];
$reference_field = [];
for ($i = 0; $i < 3; $i++) {
$target_entity = $entity_type_manager
->getStorage($this->referencedEntityType)
->create([
'type' => $this->bundle,
]);
$target_entity
->save();
$target_entities[] = $target_entity;
$reference_field[] = [
'target_id' => $target_entity
->id(),
'target_type' => $this->referencedEntityType,
];
}
$reference_field[3]['target_id'] = 99999;
$reference_field[3]['target_type'] = $this->referencedEntityType;
$target_entities[3] = NULL;
$reference_field[4]['target_id'] = NULL;
$reference_field[4]['target_type'] = $this->referencedEntityType;
$target_entities[4] = NULL;
$reference_field[5]['target_id'] = 99999;
$reference_field[5]['target_type'] = $this->entityType;
$target_entities[5] = NULL;
$reference_field[6]['target_id'] = NULL;
$reference_field[6]['target_type'] = NULL;
$target_entities[6] = NULL;
$reference_field[7] = $reference_field[0];
$target_entities[7] = $target_entities[0];
$target_entity_unsaved = $entity_type_manager
->getStorage($this->referencedEntityType)
->create([
'type' => $this->bundle,
'name' => $this
->randomString(),
]);
$reference_field[8]['entity'] = $target_entity_unsaved;
$target_entities[8] = $target_entity_unsaved;
$entity->{$this->fieldName}
->setValue($reference_field);
$entities = $entity->{$this->fieldName}
->referencedEntities();
foreach ($target_entities as $delta => $target_entity) {
if (!empty($target_entity)) {
if (!$target_entity
->isNew()) {
$this
->assertEquals($target_entity
->id(), $entities[$delta]
->id());
}
else {
$this
->assertEquals($target_entity
->label(), $entities[$delta]
->label());
}
}
else {
$this
->assertFalse(isset($entities[$delta]));
}
}
}
public function testRevisionableMultipleEntityReference() {
\Drupal::state()
->set('dynamic_entity_reference_entity_test_entities', [
$this->entityType,
$this->referencedEntityType,
]);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_with_two_base_fields', TRUE);
\Drupal::state()
->set('dynamic_entity_reference_entity_test_revisionable', TRUE);
$this
->enableModules([
'dynamic_entity_reference_entity_test',
]);
$this
->installEntitySchema($this->entityType);
$this
->installEntitySchema($this->referencedEntityType);
$referenced_entity = $this->container
->get('entity_type.manager')
->getStorage($this->entityType)
->create();
$referenced_entity
->save();
$referenced_entity_mul = $this->container
->get('entity_type.manager')
->getStorage($this->referencedEntityType)
->create();
$referenced_entity_mul
->save();
$entity = $this->container
->get('entity_type.manager')
->getStorage($this->entityType)
->create();
$entity->dynamic_references[] = $referenced_entity;
$entity->der[] = $referenced_entity_mul;
$entity
->save();
$entity = $this->container
->get('entity_type.manager')
->getStorage($this->entityType)
->loadUnchanged($entity
->id());
$this
->assertEquals($entity->dynamic_references[0]->target_id, $referenced_entity
->id());
$this
->assertEquals($entity->dynamic_references[0]->target_type, $referenced_entity
->getEntityTypeId());
$this
->assertEquals($entity->dynamic_references[0]->entity
->getName(), $referenced_entity
->getName());
$this
->assertEquals($entity->dynamic_references[0]->entity
->id(), $referenced_entity
->id());
$this
->assertEquals($entity->dynamic_references[0]->entity
->uuid(), $referenced_entity
->uuid());
$this
->assertEquals($entity->der[0]->target_id, $referenced_entity_mul
->id());
$this
->assertEquals($entity->der[0]->target_type, $referenced_entity_mul
->getEntityTypeId());
$this
->assertEquals($entity->der[0]->entity
->getName(), $referenced_entity_mul
->getName());
$this
->assertEquals($entity->der[0]->entity
->id(), $referenced_entity_mul
->id());
$this
->assertEquals($entity->der[0]->entity
->uuid(), $referenced_entity_mul
->uuid());
$database = $this->container
->get('database');
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_rev} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_rev} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_rev} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_rev} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_mulrev_property_data} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_mulrev_property_data} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_mulrev_property_data} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_mulrev_property_data} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$entity->dynamic_references[0] = $referenced_entity_mul;
$entity->der[0] = $referenced_entity;
$entity
->setNewRevision(TRUE);
$entity
->save();
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_rev_revision} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_rev_revision} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_rev_revision} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_rev_revision} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_mulrev_property_revision} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_mulrev_property_revision} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_mulrev_property_revision} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_mulrev_property_revision} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$entity = $this->container
->get('entity_type.manager')
->getStorage($this->referencedEntityType)
->create();
$entity->der[] = $referenced_entity;
$entity->dynamic_references[] = $referenced_entity_mul;
$entity
->save();
$entity = $this->container
->get('entity_type.manager')
->getStorage($this->referencedEntityType)
->loadUnchanged($entity
->id());
$this
->assertEquals($entity->dynamic_references[0]->target_id, $referenced_entity_mul
->id());
$this
->assertEquals($entity->dynamic_references[0]->target_type, $referenced_entity_mul
->getEntityTypeId());
$this
->assertEquals($entity->dynamic_references[0]->entity
->getName(), $referenced_entity_mul
->getName());
$this
->assertEquals($entity->dynamic_references[0]->entity
->id(), $referenced_entity_mul
->id());
$this
->assertEquals($entity->dynamic_references[0]->entity
->uuid(), $referenced_entity_mul
->uuid());
$this
->assertEquals($entity->der[0]->target_id, $referenced_entity
->id());
$this
->assertEquals($entity->der[0]->target_type, $referenced_entity
->getEntityTypeId());
$this
->assertEquals($entity->der[0]->entity
->getName(), $referenced_entity
->getName());
$this
->assertEquals($entity->der[0]->entity
->id(), $referenced_entity
->id());
$this
->assertEquals($entity->der[0]->entity
->uuid(), $referenced_entity
->uuid());
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_rev} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_rev} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_rev} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_rev} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_mulrev_property_data} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_mulrev_property_data} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_mulrev_property_data} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_mulrev_property_data} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$entity->dynamic_references[0] = $referenced_entity;
$entity->der[0] = $referenced_entity_mul;
$entity
->setNewRevision(TRUE);
$entity
->save();
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_rev_revision} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_rev_revision} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_rev_revision} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_rev_revision} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT dynamic_references__target_id_int FROM {entity_test_mulrev_property_revision} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT dynamic_references__target_id FROM {entity_test_mulrev_property_revision} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
$int_column = $database
->query('SELECT der__target_id_int FROM {entity_test_mulrev_property_revision} ORDER BY id, revision_id')
->fetchCol();
$str_column = $database
->query('SELECT der__target_id FROM {entity_test_mulrev_property_revision} ORDER BY id, revision_id')
->fetchCol();
$this
->assertSame($int_column, $str_column);
}
}