diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index 001b827..e1fd670 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -179,6 +179,7 @@ protected function setUp() { // StreamWrapper APIs. // @todo Move StreamWrapper management into DrupalKernel. // @see https://drupal.org/node/2028109 + $this->streamWrappers = array(); // The public stream wrapper only depends on the file_public_path setting, // which is provided by UnitTestBase::setUp(). $this->registerStreamWrapper('public', 'Drupal\Core\StreamWrapper\PublicStream'); @@ -200,7 +201,6 @@ protected function tearDown() { foreach ($this->streamWrappers as $scheme) { $this->unregisterStreamWrapper($scheme); } - $this->streamWrappers = array(); parent::tearDown(); } @@ -427,15 +427,12 @@ protected function registerStreamWrapper($scheme, $class, $type = STREAM_WRAPPER } // @todo Revamp Drupal's stream wrapper API for D8. // @see https://drupal.org/node/2028109 - // Add the stream wrapper to the file_get_stream_wrappers() static cache, - // only set the ALL type so that other types will be recalculated when - // requested. $wrappers = &drupal_static('file_get_stream_wrappers', array()); - $wrappers[STREAM_WRAPPERS_ALL][$scheme] = array( + $wrappers[$scheme] = array( 'type' => $type, 'class' => $class, ); - $wrappers[$type][$scheme] = $wrappers[STREAM_WRAPPERS_ALL][$scheme]; + $wrappers[STREAM_WRAPPERS_ALL] = $wrappers; } /** @@ -452,18 +449,9 @@ protected function unregisterStreamWrapper($scheme) { unset($this->streamWrappers[$scheme]); // @todo Revamp Drupal's stream wrapper API for D8. // @see https://drupal.org/node/2028109 - // Remove the stream wrapper from all existing types. $wrappers = &drupal_static('file_get_stream_wrappers', array()); - // @todo Some tests seem to reset the static cache to an explict - // NULL, for example the module_uninstall() call in - // \Drupal\field\Tests\FieldInfoTest::testInstanceDisabledEntityType(). - if (is_array($wrappers)) { - foreach ($wrappers as &$schemes) { - if (isset($schemes[$scheme])) { - unset($schemes[$scheme]); - } - } - } + unset($wrappers[$scheme]); + unset($wrappers[STREAM_WRAPPERS_ALL][$scheme]); } }