From c670adb15d295005aacd616966711a172f8f6ed1 Mon Sep 17 00:00:00 2001
From: xjm <xjm@65776.no-reply.drupal.org>
Date: Mon, 2 Jan 2023 11:39:30 -0600
Subject: [PATCH] Issue #3322784 by mondrake, longwave, Spokje:
 TestCase::getMockClass() is deprecated in PHPUnit 9.6 and removed from
 PHPUnit 10

(cherry picked from commit 7432d6d140901e07fbf7868b1b96bf0fa2cb5b3f)
---
 .../Drupal/Tests/Core/Entity/EntityFieldManagerTest.php      | 5 -----
 .../Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php    | 5 -----
 .../tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php | 2 +-
 .../Drupal/Tests/Core/Entity/EntityTypeRepositoryTest.php    | 3 +--
 .../Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php  | 5 -----
 5 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
index 0802812bf65b..933c678d4314 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
@@ -15,7 +15,6 @@
 use Drupal\Core\Entity\ContentEntityTypeInterface;
 use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
 use Drupal\Core\Entity\EntityFieldManager;
-use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface;
 use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
@@ -195,16 +194,12 @@ protected function setUp(): void {
    *   (optional) An array of entity type definitions.
    */
   protected function setUpEntityTypeDefinitions($definitions = []) {
-    $class = $this->getMockClass(EntityInterface::class);
     foreach ($definitions as $key => $entity_type) {
       // \Drupal\Core\Entity\EntityTypeInterface::getLinkTemplates() is called
       // by \Drupal\Core\Entity\EntityTypeManager::processDefinition() so it must
       // always be mocked.
       $entity_type->getLinkTemplates()->willReturn([]);
 
-      // Give the entity type a legitimate class to return.
-      $entity_type->getClass()->willReturn($class);
-
       $definitions[$key] = $entity_type->reveal();
     }
 
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php
index 67c78921f174..344af4a889b9 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php
@@ -6,7 +6,6 @@
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
-use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityTypeBundleInfo;
 use Drupal\Core\Entity\EntityTypeInterface;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
@@ -112,16 +111,12 @@ protected function setUp(): void {
    *   (optional) An array of entity type definitions.
    */
   protected function setUpEntityTypeDefinitions($definitions = []) {
-    $class = $this->getMockClass(EntityInterface::class);
     foreach ($definitions as $key => $entity_type) {
       // \Drupal\Core\Entity\EntityTypeInterface::getLinkTemplates() is called
       // by \Drupal\Core\Entity\EntitTypeManager::processDefinition() so it must
       // always be mocked.
       $entity_type->getLinkTemplates()->willReturn([]);
 
-      // Give the entity type a legitimate class to return.
-      $entity_type->getClass()->willReturn($class);
-
       $definitions[$key] = $entity_type->reveal();
     }
 
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php
index edb6240e1fab..f6a34fc4bdb2 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php
@@ -97,7 +97,7 @@ protected function setUp(): void {
    *   (optional) An array of entity type definitions.
    */
   protected function setUpEntityTypeDefinitions($definitions = []) {
-    $class = $this->getMockClass(EntityInterface::class);
+    $class = get_class($this->createMock(EntityInterface::class));
     foreach ($definitions as $key => $entity_type) {
       // \Drupal\Core\Entity\EntityTypeInterface::getLinkTemplates() is called
       // by \Drupal\Core\Entity\EntityTypeManager::processDefinition() so it must
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeRepositoryTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeRepositoryTest.php
index 356e573e4028..cc71399e8ac7 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeRepositoryTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeRepositoryTest.php
@@ -50,7 +50,6 @@ protected function setUp(): void {
    *   (optional) An array of entity type definitions.
    */
   protected function setUpEntityTypeDefinitions($definitions = []) {
-    $class = $this->getMockClass(EntityInterface::class);
     foreach ($definitions as $key => $entity_type) {
       // \Drupal\Core\Entity\EntityTypeInterface::getLinkTemplates() is called
       // by \Drupal\Core\Entity\EntityTypeManager::processDefinition() so it must
@@ -58,7 +57,7 @@ protected function setUpEntityTypeDefinitions($definitions = []) {
       $entity_type->getLinkTemplates()->willReturn([]);
 
       // Give the entity type a legitimate class to return.
-      $entity_type->getClass()->willReturn($class);
+      $entity_type->getClass()->willReturn(EntityInterface::class);
 
       $definitions[$key] = $entity_type->reveal();
     }
diff --git a/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php b/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php
index 6cbac0d67fdc..bff677cec036 100644
--- a/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php
+++ b/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php
@@ -6,7 +6,6 @@
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface;
 use Drupal\Core\Entity\EntityFieldManagerInterface;
-use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityTypeInterface;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Field\FieldDefinitionInterface;
@@ -78,16 +77,12 @@ protected function setUp(): void {
    *   (optional) An array of entity type definitions.
    */
   protected function setUpEntityTypeManager($definitions = []) {
-    $class = $this->getMockClass(EntityInterface::class);
     foreach ($definitions as $key => $entity_type) {
       // \Drupal\Core\Entity\EntityTypeInterface::getLinkTemplates() is called
       // by \Drupal\Core\Entity\EntityTypeManager::processDefinition() so it must
       // always be mocked.
       $entity_type->getLinkTemplates()->willReturn([]);
 
-      // Give the entity type a legitimate class to return.
-      $entity_type->getClass()->willReturn($class);
-
       $definitions[$key] = $entity_type->reveal();
     }
 
-- 
GitLab