Version 1
[yaffs-website] / web / core / modules / file / tests / file_test / src / StreamWrapper / DummyReadOnlyStreamWrapper.php
diff --git a/web/core/modules/file/tests/file_test/src/StreamWrapper/DummyReadOnlyStreamWrapper.php b/web/core/modules/file/tests/file_test/src/StreamWrapper/DummyReadOnlyStreamWrapper.php
new file mode 100644 (file)
index 0000000..c1c36af
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+
+namespace Drupal\file_test\StreamWrapper;
+
+use Drupal\Core\StreamWrapper\LocalReadOnlyStream;
+
+/**
+ * Helper class for testing the stream wrapper registry.
+ *
+ * Dummy stream wrapper implementation (dummy-readonly://).
+ */
+class DummyReadOnlyStreamWrapper extends LocalReadOnlyStream {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getName() {
+    return t('Dummy files (readonly)');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDescription() {
+    return t('Dummy wrapper for simpletest (readonly).');
+  }
+
+  public function getDirectoryPath() {
+    return \Drupal::service('site.path') . '/files';
+  }
+
+  /**
+   * Override getInternalUri().
+   *
+   * Return a dummy path for testing.
+   */
+  public function getInternalUri() {
+    return '/dummy/example.txt';
+  }
+
+  /**
+   * Override getExternalUrl().
+   *
+   * Return the HTML URI of a public file.
+   */
+  public function getExternalUrl() {
+    return '/dummy/example.txt';
+  }
+
+}