diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index e12c160669..eacf24876b 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -360,6 +360,9 @@ private function bootKernel() { $this->container = $kernel->getContainer(); + // Add session to request. + $request->setSession($this->container->get('session')); + // Ensure database tasks have been run. require_once __DIR__ . '/../../../includes/install.inc'; $connection = Database::getConnection(); diff --git a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php index a21ec29b98..c1c0527bee 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php @@ -535,6 +535,7 @@ public function testFormCacheDeletionUncached() { */ public function testExceededFileSize() { $request = new Request([FormBuilderInterface::AJAX_FORM_REQUEST => TRUE]); + $request->setSession($this->request->getSession()); $request_stack = new RequestStack(); $request_stack->push($request); $this->formBuilder = $this->getMockBuilder('\Drupal\Core\Form\FormBuilder') @@ -557,6 +558,7 @@ public function testExceededFileSize() { */ public function testGetPostAjaxRequest() { $request = new Request([FormBuilderInterface::AJAX_FORM_REQUEST => TRUE], ['form_id' => 'different_form_id']); + $request->setSession($this->request->getSession()); $request->setMethod('POST'); $this->requestStack->push($request); diff --git a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php index f0cb2f22d6..a3e31ac37d 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php +++ b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php @@ -174,6 +174,7 @@ protected function setUp() { $this->account = $this->createMock('Drupal\Core\Session\AccountInterface'); $this->themeManager = $this->createMock('Drupal\Core\Theme\ThemeManagerInterface'); $this->request = new Request(); + $this->request->setSession($this->createmock('Symfony\Component\HttpFoundation\Session\SessionInterface')); $this->eventDispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); $this->requestStack = new RequestStack(); $this->requestStack->push($this->request);