/** * Tests SqlContentEntityStorage::getRevisionTable(). * * @param string $revision_table * The revision table to be returned by the mocked entity type. * @param string $expected * The expected return value of * SqlContentEntityStorage::getRevisionTable(). * * @covers ::__construct * @covers ::getRevisionTable * * @dataProvider providerTestGetRevisionTable */ public function testGetRevisionTable($revision_table, $expected) { $this->entityType->expects($this->once())->method('isRevisionable')->will($this->returnValue(TRUE)); $this->entityType->expects($this->once())->method('getRevisionTable')->will($this->returnValue($revision_table)); $this->setUpEntityStorage(); $this->assertSame($expected, $this->entityStorage->getRevisionTable()); }
/** * Initializes common information for a revision data table. * * @param \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type * The entity type. * * @return array * A partial schema array for the revision data table. */ protected function initializeRevisionDataTable(ContentEntityTypeInterface $entity_type) { $entity_type_id = $entity_type->id(); $id_key = $entity_type->getKey('id'); $revision_key = $entity_type->getKey('revision'); $schema = array('description' => "The revision data table for {$entity_type_id} entities.", 'primary key' => array($revision_key, $entity_type->getKey('langcode')), 'indexes' => array($entity_type_id . '__id__default_langcode__langcode' => array($id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode'))), 'foreign keys' => array($entity_type_id => array('table' => $this->storage->getBaseTable(), 'columns' => array($id_key => $id_key)), $entity_type_id . '__revision' => array('table' => $this->storage->getRevisionTable(), 'columns' => array($revision_key => $revision_key)))); $this->addTableDefaults($schema); return $schema; }