From 66956c276b9f0fd4883842c4891006247c1756b4 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Wed, 24 Apr 2024 21:01:54 +0100
Subject: [PATCH] Issue #3443026 by longwave: Change @dataprovider to static in
 MenuAccessControlHandlerTest

---
 .../Kernel/MenuAccessControlHandlerTest.php   | 22 ++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/core/modules/system/tests/src/Kernel/MenuAccessControlHandlerTest.php b/core/modules/system/tests/src/Kernel/MenuAccessControlHandlerTest.php
index 5eff6b764614..bd87128d252f 100644
--- a/core/modules/system/tests/src/Kernel/MenuAccessControlHandlerTest.php
+++ b/core/modules/system/tests/src/Kernel/MenuAccessControlHandlerTest.php
@@ -5,8 +5,6 @@
 namespace Drupal\Tests\system\Kernel;
 
 use Drupal\Core\Access\AccessResult;
-use Drupal\Core\Cache\Context\CacheContextsManager;
-use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Drupal\KernelTests\KernelTestBase;
 use Drupal\system\Entity\Menu;
 use Drupal\Tests\user\Traits\UserCreationTrait;
@@ -88,15 +86,13 @@ public function testAccess($which_user, $which_entity, $view_label_access_result
     static::assertEquals($create_access_result, $this->accessControlHandler->createAccess(NULL, $user, [], TRUE));
   }
 
-  public function testAccessProvider() {
-    $c = new ContainerBuilder();
-    $cache_contexts_manager = $this->prophesize(CacheContextsManager::class);
-    $cache_contexts_manager->assertValidTokens()->willReturn(TRUE);
-    $cache_contexts_manager->reveal();
-    $c->set('cache_contexts_manager', $cache_contexts_manager);
-    \Drupal::setContainer($c);
+  public static function testAccessProvider() {
+    // RefinableCacheableDependencyTrait::addCacheContexts() only needs the
+    // container to perform an assertion, but we can't use the container here,
+    // so disable assertions for the purposes of this test.
+    $assertions = ini_set('zend.assertions', 0);
 
-    return [
+    $data = [
       'permissionless + unlocked' => [
         'permissionless',
         'unlocked',
@@ -152,6 +148,12 @@ public function testAccessProvider() {
         AccessResult::allowed()->addCacheContexts(['user.permissions']),
       ],
     ];
+
+    if ($assertions !== FALSE) {
+      ini_set('zend.assertions', $assertions);
+    }
+
+    return $data;
   }
 
 }
-- 
GitLab