only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php +++ b/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php @@ -5,6 +5,7 @@ use Drupal\Core\Form\FormState; use Drupal\Core\Session\AnonymousUserSession; use Drupal\Core\Session\UserSession; +use Drupal\Core\Site\Settings; use Drupal\KernelTests\KernelTestBase; /** @@ -101,4 +102,18 @@ public function testNoCacheToken() { $account_switcher->switchBack(); } + /** + * Tests the form cache with an overridden cache expiration. + */ + public function testCacheCustomExpiration() { + \Drupal::currentUser()->setAccount(new UserSession(['uid' => 1])); + + // Override form cache expiration so that the cached form expired yesterday. + new Settings(['form_cache_expiration' => -1 * (24*60*60), 'hash_salt' => $this->randomMachineName()]); + \Drupal::formBuilder()->setCache($this->formBuildId, $this->form, $this->formState); + + $cached_form_state = new FormState(); + $this->assertFalse(\Drupal::formBuilder()->getCache($this->formBuildId, $cached_form_state), 'Expired form not returned from cache'); + } + }