/** * Test that translation destination fails for untranslatable entities. * * @expectedException \Drupal\migrate\MigrateException * @expectedExceptionMessage This entity type does not support translation */ public function testUntranslatable() { // An entity type without a language. $entity_type = $this->prophesize(ContentEntityType::class); $entity_type->getKey('langcode')->willReturn(''); $entity_type->getKey('id')->willReturn('id'); $this->storage->getEntityType()->willReturn($entity_type->reveal()); $destination = new EntityTestDestination(['translations' => TRUE], '', [], $this->migration->reveal(), $this->storage->reveal(), [], $this->entityManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal()); $destination->getIds(); }
/** * Test entity load failure. * * @covers ::getEntity */ public function testGetEntityLoadFailure() { $destination = $this->getEntityRevisionDestination([]); $entity_type = $this->prophesize('\\Drupal\\Core\\Entity\\EntityTypeInterface'); $entity_type->getKey('id')->willReturn('nid'); $entity_type->getKey('revision')->willReturn('vid'); $this->storage->getEntityType()->willReturn($entity_type->reveal()); // Return a failed load and make sure we don't fail and we return FALSE. $this->storage->load(1)->shouldBeCalled()->willReturn(FALSE); $row = new Row(['nid' => 1, 'vid' => 2], ['nid' => 1, 'vid' => 2]); $row->setDestinationProperty('nid', 1); $this->assertFalse($destination->getEntity($row, [])); }
/** * {@inheritdoc} */ public static function postDelete(EntityStorageInterface $storage, array $entities) { static::invalidateTagsOnDelete($storage->getEntityType(), $entities); }
/** * {@inheritdoc} */ public function calculateDependencies() { $this->addDependency('module', $this->storage->getEntityType()->getProvider()); return $this->dependencies; }
/** * Returns a specific entity key. * * @param string $key * The name of the entity key to return. * * @return string|bool * The entity key, or FALSE if it does not exist. * * @see \Drupal\Core\Entity\EntityTypeInterface::getKeys() */ protected function getKey($key) { return $this->storage->getEntityType()->getKey($key); }
/** * {@inheritdoc} */ public function sortSearchPages($search_pages) { $entity_type = $this->storage->getEntityType(); uasort($search_pages, array($entity_type->getClass(), 'sort')); return $search_pages; }