From 8acb6951ed4dc649d6e6834ec9c7065a9ea367bc Mon Sep 17 00:00:00 2001 From: Greg Anderson Date: Fri, 22 Apr 2016 12:48:28 -0700 Subject: [PATCH] Annotated commands tests for Drupal 6. --- tests/annotatedCommandTest.php | 22 +++++-------------- .../modules/d6/woot/Command/.gitignore | 1 + tests/resources/modules/d6/woot/woot.info | 4 ++++ tests/resources/modules/d6/woot/woot.module | 22 +++++++++++++++++++ 4 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 tests/resources/modules/d6/woot/Command/.gitignore create mode 100644 tests/resources/modules/d6/woot/woot.info create mode 100644 tests/resources/modules/d6/woot/woot.module diff --git a/tests/annotatedCommandTest.php b/tests/annotatedCommandTest.php index 4359d6f0ec..448acd05f8 100644 --- a/tests/annotatedCommandTest.php +++ b/tests/annotatedCommandTest.php @@ -17,12 +17,7 @@ public function testExecute() { ); // Copy the 'woot' module over to the Drupal site we just set up. - if (UNISH_DRUPAL_MAJOR_VERSION == 8) { - $this->setupModulesForDrupal8($root); - } - else { - $this->setupModulesForDrupal6and7($root); - } + $this->setupModulesForTests($root); // Enable out module. This will also clear the commandfile cache. $this->drush('pm-enable', array('woot'), $options, NULL, NULL, self::EXIT_SUCCESS); @@ -81,18 +76,13 @@ public function testExecute() { $this->drush('cache-clear', array('drush'), $options, NULL, NULL, self::EXIT_SUCCESS); } - public function setupModulesForDrupal8($root) { - $woot8Module = __DIR__ . '/resources/modules/d8/woot'; - $modulesDir = "$root/modules"; - \symlink($woot8Module, "$modulesDir/woot"); - } - - public function setupModulesForDrupal6and7($root) { - $wootModule = __DIR__ . '/resources/modules/d7/woot'; - $woot8Module = __DIR__ . '/resources/modules/d8/woot'; + public function setupModulesForTests($root) { + $wootModule = __DIR__ . '/resources/modules/d' . UNISH_DRUPAL_MAJOR_VERSION . '/woot'; $modulesDir = "$root/sites/all/modules"; + $this->mkdir($modulesDir); \symlink($wootModule, "$modulesDir/woot"); - if (!file_exists("$wootModule/Command/WootCommands.php")) { + if ((UNISH_DRUPAL_MAJOR_VERSION < 8) && !file_exists("$wootModule/Command/WootCommands.php")) { + $woot8Module = __DIR__ . '/resources/modules/d8/woot'; \symlink("$woot8Module/src/Command/WootCommands.php", "$wootModule/Command/WootCommands.php"); } } diff --git a/tests/resources/modules/d6/woot/Command/.gitignore b/tests/resources/modules/d6/woot/Command/.gitignore new file mode 100644 index 0000000000..772f99a1e4 --- /dev/null +++ b/tests/resources/modules/d6/woot/Command/.gitignore @@ -0,0 +1 @@ +WootCommands.php diff --git a/tests/resources/modules/d6/woot/woot.info b/tests/resources/modules/d6/woot/woot.info new file mode 100644 index 0000000000..45f4a3ccb2 --- /dev/null +++ b/tests/resources/modules/d6/woot/woot.info @@ -0,0 +1,4 @@ +name = woot +description = Woot Mightily +core = 6.x +files[] = woot.module diff --git a/tests/resources/modules/d6/woot/woot.module b/tests/resources/modules/d6/woot/woot.module new file mode 100644 index 0000000000..f51b34a5be --- /dev/null +++ b/tests/resources/modules/d6/woot/woot.module @@ -0,0 +1,22 @@ + 'Woot', + 'description' => 'Woot mightily.', + 'page callback' => 'woot_page', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + ); + + return $items; +} + +function woot_page() { + return array('#markup' => 'Woot!'); +}