diff --git a/core/modules/comment/src/Tests/CommentOrphanedTest.php b/core/modules/comment/src/Tests/CommentOrphanedTest.php index 84e4724..962e834 100644 --- a/core/modules/comment/src/Tests/CommentOrphanedTest.php +++ b/core/modules/comment/src/Tests/CommentOrphanedTest.php @@ -30,10 +30,14 @@ public function testDeleteOrphanedComment() { /** @var \Drupal\Core\Entity\EntityManagerInterface $manager */ $manager = $this->container->get('entity.manager'); - // Mess with the comments to make them orphaned. We only know how to do - // this with SQL based entity storage. + // We only know how to orphan comments on SQL based entity storage. $storage = $manager->getStorage('comment'); if (in_array('Drupal\Core\Entity\Sql\SqlEntityStorageInterface', class_implements($storage))) { + + // Make sure we have a comment. + $this->postComment($this->node, $this->randomMachineName()); + + // Mess with the comments to make them orphaned. $manager->clearCachedDefinitions(); $manager->getDefinition('comment')->setHandlerClass('storage', 'Drupal\comment_test\CommentTestSqlEntityStorage'); $storage = $manager->getStorage('comment'); @@ -42,6 +46,7 @@ public function testDeleteOrphanedComment() { // Now load and delete these comments, and implicitly test that nothing // breaks. + $storage->resetCache(); $entities = $storage->loadMultiple($ids); $storage->delete($entities); }