X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FKernelTests%2FCore%2FForm%2FFormCacheTest.php;h=f6fb4f8713a42a26d00c7ef522a36f11378ed6ae;hp=6425a3099d5c58db401320b595d094ca58020b30;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php b/web/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php index 6425a3099..f6fb4f871 100644 --- a/web/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php +++ b/web/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php @@ -5,6 +5,7 @@ namespace Drupal\KernelTests\Core\Form; 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,16 @@ class FormCacheTest extends KernelTestBase { $account_switcher->switchBack(); } + /** + * Tests the form cache with an overridden cache expiration. + */ + public function testCacheCustomExpiration() { + // 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'); + } + }