Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / drush / drush / tests / TestModuleHelperTrait.php
diff --git a/vendor/drush/drush/tests/TestModuleHelperTrait.php b/vendor/drush/drush/tests/TestModuleHelperTrait.php
new file mode 100644 (file)
index 0000000..82dc3de
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+namespace Unish;
+
+use Symfony\Component\Filesystem\Filesystem;
+use Webmozart\PathUtil\Path;
+
+/**
+ * Helper for installing testing modules.
+ */
+trait TestModuleHelperTrait
+{
+    /**
+     * Copies the testing modules from a specific path into Drupal.
+     *
+     * @param array $modules A list of testing modules.
+     * @param string $sourcePath The path under which the modules are placed.
+     */
+    public function setupModulesForTests(array $modules, $sourcePath)
+    {
+        $webRoot = $this->webroot();
+        $fileSystem = new Filesystem();
+        foreach ($modules as $module) {
+            $sourceDir = Path::join($sourcePath, $module);
+            $this->assertFileExists($sourceDir);
+            $targetDir = Path::join($webRoot, "modules/unish/$module");
+            $fileSystem->mkdir($targetDir);
+            $this->recursiveCopy($sourceDir, $targetDir);
+        }
+    }
+}