diff --git a/README.txt b/README.txt index 3948da2..05ec991 100644 --- a/README.txt +++ b/README.txt @@ -138,6 +138,43 @@ API Overview See "The developer's guide to Feeds": http://drupal.org/node/622700 +Running the Drush integration tests +=================================== + +In order the run Drush integration tests, Drush itself needs to be installed +with its *dev dependencies*. Furthermore, the phpunit version that comes with +Drush should be used for running the tests (instead of a globally installed +phpunit), as that one has proven to be compatible with the Drush tests. + + 1. Git clone of Drush 8. + + git clone --branch 8.x https://github.com/drush-ops/drush.git + cd drush + + 2. Install Drush with dev dependencies using Composer. + + composer install + + And ensure that the following text is displayed: + + "Loading composer repositories with package information + Installing dependencies (including require-dev) from lock file" + + Especially note that Composer says 'including require-dev'. This means that + the Drush dev dependencies are installed (including phpunit). + + 3. Execute a command like the following: + + UNISH_NO_TIMEOUTS=1 UNISH_DRUPAL_MAJOR_VERSION=7 /path/to/drush/vendor/bin/phpunit --configuration /path/to/drush/tests /path/to/feeds/tests/drush + + Replace '/path/to' with the appropriate path to the directory in question. + Also be sure to point to the phpunit version that comes with Drush. + + So if Drush is installed in /users/megachriz/drush and the Feeds module is + located at /users/megachriz/Sites/drupal7/sites/all/modules/feeds: + + UNISH_NO_TIMEOUTS=1 UNISH_DRUPAL_MAJOR_VERSION=7 /users/megachriz/drush/vendor/bin/phpunit --configuration /users/megachriz/drush/tests /users/megachriz/Sites/drupal7/sites/all/modules/feeds/tests/drush + Debugging ========= diff --git a/tests/drush/feedsDrushTest.php b/tests/drush/feedsDrushTest.php index fc16a90..e760017 100644 --- a/tests/drush/feedsDrushTest.php +++ b/tests/drush/feedsDrushTest.php @@ -9,7 +9,10 @@ namespace Unish; * @code * UNISH_NO_TIMEOUTS=1 UNISH_DRUPAL_MAJOR_VERSION=7 /path/to/drush/vendor/bin/phpunit --configuration /path/to/drush/tests /path/to/feeds/tests/drush * @endcode - * Replace '/path/to' with the appriopiate path to the directory in question. + * Replace '/path/to' with the appropriate path to the directory in question. + * Also be sure to have Drush installed with its dev dependencies and point to + * the phpunit version that comes with Drush. Fore more information, see the + * Feeds README file. * * @group commands */ @@ -31,12 +34,37 @@ class feedsDrushTest extends CommandUnishTestCase { 'yes' => NULL, ); + // Copy the local Feeds directory to the test directory. + $this->copyLocalFeedsDirToTestDir(); + // Enable the feeds_import module. $this->execDrush('pm-enable', array('feeds')); $this->execDrush('pm-enable', array('feeds_import')); } /** + * Copies the local Feeds directory to the directory used in the test. + */ + protected function copyLocalFeedsDirToTestDir() { + $source = dirname(dirname(dirname(__FILE__))); + $dest = $this->getFeedsDir(); + + mkdir($dest, 0755, TRUE); + foreach ( + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), + \RecursiveIteratorIterator::SELF_FIRST) as $item + ) { + if ($item->isDir()) { + mkdir($dest . "/" . $iterator->getSubPathName()); + } + else { + copy($item, $dest . "/" . $iterator->getSubPathName()); + } + } + } + + /** * Wrapper around drush to always add the site options. * * @param string command