diff --git a/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ContentEntityTest.php b/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ContentEntityTest.php index c183eaf..85d0340 100755 --- a/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ContentEntityTest.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ContentEntityTest.php @@ -33,7 +33,7 @@ public function testEntitySource() { $values = $source->current()->getSource(); $this->assertEquals('example@example.com', $values['mail']); $this->assertEquals('user123', $values['name']); - $this->assertEquals(1, $values['uid']); + $this->assertEquals($this->user->id(), $values['uid']); // File testing. $definition['source']['entity_type'] = 'file'; @@ -70,7 +70,7 @@ public function testEntitySource() { $values = $source->current()->getSource(); $this->assertEquals($this->bundle, $values['type']); $this->assertEquals('node', $values['entity_type']); - $this->assertEquals(1, $values['nid']); + $this->assertEquals($this->node->id(), $values['nid']); $this->assertEquals(1, $values['status']); $this->assertEquals('Apples', $values['title']); diff --git a/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ContentEntityTestBase.php b/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ContentEntityTestBase.php index f08e0d6..8837bee 100755 --- a/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ContentEntityTestBase.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ContentEntityTestBase.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\d8; -use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait; +use Drupal\Core\Entity\EntityInterface; use Drupal\file\Entity\File; use Drupal\media\Entity\Media; use Drupal\media\Entity\MediaType; @@ -163,4 +163,19 @@ protected function createMediaType($media_source_name) { return $media_type; } + /** + * Reloads the given entity from the storage and returns it. + * + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity to be reloaded. + * + * @return \Drupal\Core\Entity\EntityInterface + * The reloaded entity. + */ + protected function reloadEntity(EntityInterface $entity) { + $controller = $this->container->get('entity_type.manager')->getStorage($entity->getEntityTypeId()); + $controller->resetCache([$entity->id()]); + return $controller->load($entity->id()); + } + } diff --git a/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d8/TermTest.php b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d8/TermTest.php index 471eaf3..a39ca55 100755 --- a/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d8/TermTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d8/TermTest.php @@ -48,6 +48,7 @@ protected function setUp() { $this->installEntitySchema('taxonomy_term'); $this->installEntitySchema('taxonomy_vocabulary'); + $this->installSchema('node', 'node_access'); // Create a vocabulary. $vocabulary = Vocabulary::create([ @@ -95,8 +96,10 @@ protected function setUp() { 'parent' => $term->id(), ]); $term2->save(); + $this->user = $this->reloadEntity($this->user); $this->user->set($this->fieldName, $term->id()); $this->user->save(); + $this->node = $this->reloadEntity($this->node); $this->node->set($this->fieldName, $term->id()); $this->node->save(); }