diff --git a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php index 7a10af0..5bc4a7d 100644 --- a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php +++ b/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php @@ -8,6 +8,7 @@ use Drupal\Core\Asset\AssetCollectionOptimizerInterface; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** * Optimizes CSS assets. @@ -38,7 +39,7 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface { /** * The state key/value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -51,7 +52,7 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface { * The optimizer for a single CSS asset. * @param \Drupal\Core\Asset\AssetDumperInterface * The dumper for optimized CSS assets. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @param \Drupal\Core\KeyValueStore\StateInterface * The state key/value store. */ public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, StateInterface $state) { diff --git a/core/lib/Drupal/Core/KeyValueStore/State.php b/core/lib/Drupal/Core/KeyValueStore/State.php index 75b950e..57b96dc 100644 --- a/core/lib/Drupal/Core/KeyValueStore/State.php +++ b/core/lib/Drupal/Core/KeyValueStore/State.php @@ -113,4 +113,11 @@ public function delete($key) { $this->deleteMultiple(array($key)); } + /** + * {@inheritdoc} + */ + public function resetCache() { + $this->cache = array(); + } + } diff --git a/core/lib/Drupal/Core/KeyValueStore/StateInterface.php b/core/lib/Drupal/Core/KeyValueStore/StateInterface.php index 36f705c..9e248d8 100644 --- a/core/lib/Drupal/Core/KeyValueStore/StateInterface.php +++ b/core/lib/Drupal/Core/KeyValueStore/StateInterface.php @@ -68,4 +68,11 @@ public function delete($key); */ public function deleteMultiple(array $keys); + /** + * Resets the static cache. + * + * This is only needed for Simpletest. + */ + public function resetCache(); + } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php index 915e4bb..fefb9fd 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php @@ -75,6 +75,7 @@ public function testLanguageBlockVisibility() { // Reset the static cache of the language list. drupal_static_reset('language_list'); + \Drupal::state()->resetCache(); // Check that a page has a block. $this->drupalget('', array('language' => language_load('en'))); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php index 96305bd..b6fb820 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php @@ -38,6 +38,8 @@ function setUp() { * 'insert', etc. */ function assertFileHooksCalled($expected) { + \Drupal::state()->resetCache(); + // Determine which hooks were called. $actual = array_keys(array_filter(file_test_get_all_calls())); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php index 1fb8c85..3381d44 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php @@ -72,6 +72,8 @@ function testLanguageConfiguration() { ); $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->assertOptionSelected('edit-site-default-language', 'fr', 'Default language updated.'); + + \Drupal::state()->resetCache(); $this->assertEqual($this->getUrl(), url('admin/config/regional/settings', array('absolute' => TRUE)), 'Correct page redirection.'); // Check if a valid language prefix is added after changing the default diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php index 8b2190d..b05808d 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php @@ -72,6 +72,7 @@ function testLanguageList() { ); $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->assertNoOptionSelected('edit-site-default-language', 'en', 'Default language updated.'); + \Drupal::state()->resetCache(); $this->assertEqual($this->getUrl(), url($path, array('absolute' => TRUE)), 'Correct page redirection.'); // Ensure we can't delete the default language. @@ -96,6 +97,7 @@ function testLanguageList() { 'site_default_language' => 'en', ); $this->drupalPostForm($path, $edit, t('Save configuration')); + \Drupal::state()->resetCache(); // Ensure 'delete' link works. $this->drupalGet('admin/config/regional/language'); $this->clickLink(t('Delete')); @@ -125,6 +127,7 @@ function testLanguageList() { $this->drupalPostForm('admin/config/regional/language/delete/fr', array(), t('Delete')); // Get the count of languages. drupal_static_reset('language_list'); + \Drupal::state()->resetCache(); $languages = language_list(); // We need raw here because %language and %langcode will add HTML. $t_args = array('%language' => 'French', '%langcode' => 'fr'); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php index 8cd217b..dff7ec3 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php @@ -136,6 +136,7 @@ function testStandalonePoFile() { $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); $this->assertNoText(t('No strings available.'), 'String overwritten by imported string.'); // This import should have changed number of plural forms. + \Drupal::state()->resetCache(); $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); $this->assert($locale_plurals['fr']['plurals'] == 3, 'Plural numbers changed.'); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php index 3d20f6d..1ed7800 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php @@ -130,6 +130,7 @@ function testUpdateCheckStatus() { // Get status of translation sources at both local and remote locations. $this->drupalGet('admin/reports/translations/check'); + \Drupal::state()->resetCache(); $result = locale_translation_get_status(); $this->assertEqual($result['contrib_module_one']['de']->type, LOCALE_TRANSLATION_REMOTE, 'Translation of contrib_module_one found'); $this->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestamp_new, 'Translation timestamp found'); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php index 66ea769..f07f3e1 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php @@ -55,6 +55,7 @@ function testNodeTypeCustomizationPersistence() { $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall')); $this->drupalPostForm(NULL, array(), t('Uninstall')); $forum = entity_load('node_type', 'forum'); + \Drupal::state()->resetCache(); $this->assertFalse($forum->isLocked(), 'Forum node type is not locked'); $this->drupalGet('node/add'); $this->assertNoText('forum', 'forum type is no longer found on node/add'); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 42f217d..20f000a 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -2367,6 +2367,7 @@ protected function drupalGetSettings() { * An array containing e-mail messages captured during the current test. */ protected function drupalGetMails($filter = array()) { + \Drupal::state()->resetCache(); $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array(); $filtered_emails = array(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php b/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php index b452e69..be395541 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php @@ -54,6 +54,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_1'); $this->drupalPostForm('batch-test/simple', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch with simple operations performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_1'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); @@ -61,6 +62,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_2'); $this->drupalPostForm('batch-test/simple', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_2'), 'Batch with multistep operation performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_2'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); @@ -68,6 +70,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_3'); $this->drupalPostForm('batch-test/simple', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_3'), 'Batch with simple and multistep operations performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_3'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); @@ -75,6 +78,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_4'); $this->drupalPostForm('batch-test/simple', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_4'), 'Nested batch performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_4'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 68f6303..9407d70 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -113,6 +113,7 @@ function testEntityFormLanguage() { $node->getTranslation($langcode2)->body->value = $this->randomName(16); $node->save(); $this->drupalGet($langcode2 . '/node/' . $node->id() . '/edit'); + \Drupal::state()->resetCache(); $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE; $this->assertTrue($langcode2 == $form_langcode, "Node edit form language is $langcode2."); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php index 111c118..374077c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php @@ -156,6 +156,7 @@ function testCustom403And404Pages() { // Check that the initial trail (during the Drupal bootstrap) matches // what we expect. + \Drupal::state()->resetCache(); $initial_trail = \Drupal::state()->get('menu_test.active_trail_initial') ?: array(); $this->assertEqual(count($initial_trail), count($expected_trail[$status_code]['initial']), format_string('The initial active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array( '@status_code' => $status_code, diff --git a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php index 6fe28f2..996dea4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php @@ -68,6 +68,7 @@ function testAutomaticCron() { \Drupal::state()->set('system.cron_last', $cron_last); $this->drupalGet(''); sleep(1); + \Drupal::state()->resetCache(); $this->assertTrue($cron_last < \Drupal::state()->get('system.cron_last'), 'Cron runs when the cron threshold is passed.'); // Disable the cron threshold through the interface. diff --git a/core/tests/Drupal/Tests/Core/PrivateKeyTest.php b/core/tests/Drupal/Tests/Core/PrivateKeyTest.php index a77a939..8e62f1c 100644 --- a/core/tests/Drupal/Tests/Core/PrivateKeyTest.php +++ b/core/tests/Drupal/Tests/Core/PrivateKeyTest.php @@ -52,7 +52,7 @@ public function setUp() { parent::setUp(); $this->key = Crypt::randomStringHashed(55); - $this->state = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreInterface'); + $this->state = $this->getMock('Drupal\Core\KeyValueStore\StateInterface'); $this->privateKey = new PrivateKey($this->state); }