X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FTest%2FRefreshVariablesTrait.php;fp=web%2Fcore%2Flib%2FDrupal%2FCore%2FTest%2FRefreshVariablesTrait.php;h=974d96ed66b8fca806ccb1eaa9ac81360c5c2fee;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/lib/Drupal/Core/Test/RefreshVariablesTrait.php b/web/core/lib/Drupal/Core/Test/RefreshVariablesTrait.php new file mode 100644 index 000000000..974d96ed6 --- /dev/null +++ b/web/core/lib/Drupal/Core/Test/RefreshVariablesTrait.php @@ -0,0 +1,38 @@ +drupalPostForm() with a + * changed value would update configuration to reflect that change, but in the + * thread that made the call (thread running the test) the changed values + * would not be picked up. + * + * This method clears the cache and loads a fresh copy. + */ + protected function refreshVariables() { + // Clear the tag cache. + \Drupal::service('cache_tags.invalidator')->resetChecksums(); + foreach (Cache::getBins() as $backend) { + if (is_callable([$backend, 'reset'])) { + $backend->reset(); + } + } + + \Drupal::service('config.factory')->reset(); + \Drupal::service('state')->resetCache(); + } + +}