summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/file_test.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest/tests/file_test.module')
-rw-r--r--modules/simpletest/tests/file_test.module43
1 files changed, 43 insertions, 0 deletions
diff --git a/modules/simpletest/tests/file_test.module b/modules/simpletest/tests/file_test.module
index 3873c1ec9..dc6a56b4e 100644
--- a/modules/simpletest/tests/file_test.module
+++ b/modules/simpletest/tests/file_test.module
@@ -24,6 +24,19 @@ function file_test_menu() {
}
/**
+ * Implement hook_stream_wrappers().
+ */
+function file_test_stream_wrappers() {
+ return array(
+ 'dummy' => array(
+ 'name' => t('Dummy files'),
+ 'class' => 'DrupalDummyStreamWrapper',
+ 'description' => t('Dummy wrapper for simpletest.'),
+ ),
+ );
+}
+
+/**
* Form to test file uploads.
*/
function _file_test_form(&$form_state) {
@@ -238,3 +251,33 @@ function file_test_file_move($file, $source) {
function file_test_file_delete($file) {
_file_test_log_call('delete', array($file));
}
+
+/**
+ * Helper class for testing the stream wrapper registry.
+ *
+ * Dummy stream wrapper implementation (dummy://).
+ */
+class DrupalDummyStreamWrapper extends DrupalLocalStreamWrapper {
+ function getDirectoryPath() {
+ return variable_get('stream_public_path', 'sites/default/files');
+ }
+
+ /**
+ * Override getInternalUri().
+ *
+ * Return a dummy path for testing.
+ */
+ function getInternalUri() {
+ return '/dummy/example.txt';
+ }
+
+ /**
+ * Override getExternalUrl().
+ *
+ * Return the HTML URI of a public file.
+ */
+ function getExternalUrl() {
+ return '/dummy/example.txt';
+ }
+}
+