Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / drush / drush / tests / CommandInfoAlterTest.php
diff --git a/vendor/drush/drush/tests/CommandInfoAlterTest.php b/vendor/drush/drush/tests/CommandInfoAlterTest.php
new file mode 100644 (file)
index 0000000..afd4b2e
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace Unish;
+
+use Webmozart\PathUtil\Path;
+
+/**
+ * @group commands
+ *
+ */
+class CommandInfoAlterTest extends CommandUnishTestCase
+{
+    use TestModuleHelperTrait;
+
+    /**
+     * Tests command info alter.
+     */
+    public function testCommandInfoAlter()
+    {
+        $this->setUpDrupal(1, true);
+        $this->setupModulesForTests(['woot'], Path::join(__DIR__, 'resources/modules/d8'));
+        $this->drush('pm-enable', ['woot']);
+        $this->drush('woot:altered', [], ['help' => true, 'debug' => true]);
+        $this->assertNotContains('woot-initial-alias', $this->getOutput());
+        $this->assertContains('woot-new-alias', $this->getOutput());
+
+        // Check the debug messages.
+        $this->assertContains('[debug] Commands are potentially altered in Drupal\woot\WootCommandInfoAlterer.', $this->getErrorOutput());
+        $this->assertContains("[debug] Module 'woot' changed the alias of 'woot:altered' command into 'woot-new-alias' in Drupal\woot\WootCommandInfoAlterer::alterCommandInfo().", $this->getErrorOutput());
+
+        // Try to run the command with the initial alias.
+        $this->drush('woot-initial-alias', [], [], null, null, self::EXIT_ERROR);
+        // Run the command with the altered alias.
+        $this->drush('woot-new-alias');
+    }
+}