diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index b98085b..8111e17 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -144,16 +144,16 @@ protected function setUp() { // In order to use theme functions default theme config needs to exist. \Drupal::config('system.theme')->set('default', 'stark'); - // Tests based on DrupalUnitTestBase are entitled to use Drupal's File API. + // Tests based on this class are entitled to use Drupal's File and + // StreamWrapper APIs. + // @todo Move StreamWrapper management into DrupalKernel. + // @see https://drupal.org/node/2028109 + // 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'); - - // The private and temporary stream wrappers depend on the system.file - // configuration. If System module was enabled, the test will most likely - // install System module's configuration, so we can register them here. - if (in_array('system', $modules)) { - $this->registerStreamWrapper('private', 'Drupal\Core\StreamWrapper\PrivateStream'); - $this->registerStreamWrapper('temporary', 'Drupal\Core\StreamWrapper\TemporaryStream'); - } + // The temporary stream wrapper is able to operate both with and without + // configuration. + $this->registerStreamWrapper('temporary', 'Drupal\Core\StreamWrapper\TemporaryStream'); } protected function tearDown() { @@ -162,6 +162,8 @@ protected function tearDown() { // of this test leaks into the parent environment. Unlike all other global // state variables in Drupal, stream wrappers are a global state construct // of PHP core, which has to be maintained manually. + // @todo Move StreamWrapper management into DrupalKernel. + // @see https://drupal.org/node/2028109 foreach ($this->streamWrappers as $scheme) { $this->unregisterStreamWrapper($scheme); } @@ -391,6 +393,7 @@ protected function registerStreamWrapper($scheme, $class, $type = STREAM_WRAPPER stream_wrapper_register($scheme, $class, STREAM_IS_URL); } // @todo Revamp Drupal's stream wrapper API for D8. + // @see https://drupal.org/node/2028109 $wrappers = &drupal_static('file_get_stream_wrappers'); $wrappers[$scheme] = array( 'type' => $type, @@ -412,6 +415,7 @@ protected function unregisterStreamWrapper($scheme) { stream_wrapper_unregister($scheme); unset($this->streamWrappers[$scheme]); // @todo Revamp Drupal's stream wrapper API for D8. + // @see https://drupal.org/node/2028109 $wrappers = &drupal_static('file_get_stream_wrappers'); unset($wrappers[$scheme]); unset($wrappers[STREAM_WRAPPERS_ALL][$scheme]); diff --git a/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php b/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php index 6857149..d3d913c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php @@ -39,6 +39,7 @@ function setUp() { parent::setUp(); $this->installConfig(array('system')); + $this->registerStreamWrapper('private', 'Drupal\Core\StreamWrapper\PrivateStream'); if (isset($this->scheme)) { $this->registerStreamWrapper($this->scheme, $this->classname); diff --git a/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php b/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php index 779ba12..e02cd07 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php @@ -12,7 +12,18 @@ */ class ReadOnlyStreamWrapperTest extends FileTestBase { + /** + * A stream wrapper scheme to register for the test. + * + * @var string + */ protected $scheme = 'dummy-readonly'; + + /** + * A fully-qualified stream wrapper class name to register for the test. + * + * @var string + */ protected $classname = 'Drupal\file_test\DummyReadOnlyStreamWrapper'; public static function getInfo() { diff --git a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileDirectoryTest.php b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileDirectoryTest.php index af39312..55946b8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileDirectoryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileDirectoryTest.php @@ -19,7 +19,18 @@ class RemoteFileDirectoryTest extends DirectoryTest { */ public static $modules = array('file_test'); + /** + * A stream wrapper scheme to register for the test. + * + * @var string + */ protected $scheme = 'dummy-remote'; + + /** + * A fully-qualified stream wrapper class name to register for the test. + * + * @var string + */ protected $classname = 'Drupal\file_test\DummyRemoteStreamWrapper'; public static function getInfo() { diff --git a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileScanDirectoryTest.php b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileScanDirectoryTest.php index 93e2016..ded05b4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileScanDirectoryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileScanDirectoryTest.php @@ -19,7 +19,18 @@ class RemoteFileScanDirectoryTest extends ScanDirectoryTest { */ public static $modules = array('file_test'); + /** + * A stream wrapper scheme to register for the test. + * + * @var string + */ protected $scheme = 'dummy-remote'; + + /** + * A fully-qualified stream wrapper class name to register for the test. + * + * @var string + */ protected $classname = 'Drupal\file_test\DummyRemoteStreamWrapper'; public static function getInfo() { diff --git a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedCopyTest.php b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedCopyTest.php index d81213e..4bf8864 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedCopyTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedCopyTest.php @@ -19,7 +19,18 @@ class RemoteFileUnmanagedCopyTest extends UnmanagedCopyTest { */ public static $modules = array('file_test'); + /** + * A stream wrapper scheme to register for the test. + * + * @var string + */ protected $scheme = 'dummy-remote'; + + /** + * A fully-qualified stream wrapper class name to register for the test. + * + * @var string + */ protected $classname = 'Drupal\file_test\DummyRemoteStreamWrapper'; public static function getInfo() { diff --git a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedDeleteRecursiveTest.php b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedDeleteRecursiveTest.php index a43c3a1..8cdc8d5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedDeleteRecursiveTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedDeleteRecursiveTest.php @@ -19,7 +19,18 @@ class RemoteFileUnmanagedDeleteRecursiveTest extends UnmanagedDeleteRecursiveTes */ public static $modules = array('file_test'); + /** + * A stream wrapper scheme to register for the test. + * + * @var string + */ protected $scheme = 'dummy-remote'; + + /** + * A fully-qualified stream wrapper class name to register for the test. + * + * @var string + */ protected $classname = 'Drupal\file_test\DummyRemoteStreamWrapper'; public static function getInfo() { diff --git a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedDeleteTest.php b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedDeleteTest.php index d6a9b07..f1105df 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedDeleteTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedDeleteTest.php @@ -19,7 +19,18 @@ class RemoteFileUnmanagedDeleteTest extends UnmanagedDeleteTest { */ public static $modules = array('file_test'); + /** + * A stream wrapper scheme to register for the test. + * + * @var string + */ protected $scheme = 'dummy-remote'; + + /** + * A fully-qualified stream wrapper class name to register for the test. + * + * @var string + */ protected $classname = 'Drupal\file_test\DummyRemoteStreamWrapper'; public static function getInfo() { diff --git a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedMoveTest.php b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedMoveTest.php index 52a74fb..32d35ad 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedMoveTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedMoveTest.php @@ -19,7 +19,18 @@ class RemoteFileUnmanagedMoveTest extends UnmanagedMoveTest { */ public static $modules = array('file_test'); + /** + * A stream wrapper scheme to register for the test. + * + * @var string + */ protected $scheme = 'dummy-remote'; + + /** + * A fully-qualified stream wrapper class name to register for the test. + * + * @var string + */ protected $classname = 'Drupal\file_test\DummyRemoteStreamWrapper'; public static function getInfo() { diff --git a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedSaveDataTest.php b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedSaveDataTest.php index 8dfd0e9..1e0b9ea 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedSaveDataTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/RemoteFileUnmanagedSaveDataTest.php @@ -19,7 +19,18 @@ class RemoteFileUnmanagedSaveDataTest extends UnmanagedSaveDataTest { */ public static $modules = array('file_test'); + /** + * A stream wrapper scheme to register for the test. + * + * @var string + */ protected $scheme = 'dummy-remote'; + + /** + * A fully-qualified stream wrapper class name to register for the test. + * + * @var string + */ protected $classname = 'Drupal\file_test\DummyRemoteStreamWrapper'; public static function getInfo() { diff --git a/core/modules/system/lib/Drupal/system/Tests/File/StreamWrapperTest.php b/core/modules/system/lib/Drupal/system/Tests/File/StreamWrapperTest.php index e095ed4..35f85ab 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/StreamWrapperTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/StreamWrapperTest.php @@ -21,7 +21,18 @@ class StreamWrapperTest extends FileTestBase { */ public static $modules = array('file_test'); + /** + * A stream wrapper scheme to register for the test. + * + * @var string + */ protected $scheme = 'dummy'; + + /** + * A fully-qualified stream wrapper class name to register for the test. + * + * @var string + */ protected $classname = 'Drupal\file_test\DummyStreamWrapper'; public static function getInfo() { diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php index 65755af..8590e52 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php @@ -37,6 +37,6 @@ function testFileSaveData() { $this->assertTrue($filepath, 'Unnamed file saved correctly.'); $this->assertEqual('asdf.txt', drupal_basename($filepath), 'File was named correctly.'); $this->assertEqual($contents, file_get_contents($filepath), 'Contents of the file are correct.'); - $this->assertFilePermissions($filepath, 0777, 'file_chmod_file setting is respected.'); + $this->assertFilePermissions($filepath, 0777); } }