quickDrupalTest.php

  1. 8.0.x tests/quickDrupalTest.php
  2. 6.x tests/quickDrupalTest.php
  3. 7.x tests/quickDrupalTest.php
  4. 5.x tests/quickDrupalTest.php
  5. master tests/quickDrupalTest.php

Namespace

Unish

Classes

Namesort descending Description
quickDrupalCase core-quick-drupal tests.

File

tests/quickDrupalTest.php
View source
  1. <?php
  2. namespace Unish;
  3. /**
  4. * core-quick-drupal tests.
  5. *
  6. * @group quick-drupal
  7. * @group slow
  8. */
  9. class quickDrupalCase extends CommandUnishTestCase {
  10. /**
  11. * Path to test make files.
  12. */
  13. protected $makefile_path;
  14. /**
  15. * Initialize $makefile_path.
  16. */
  17. function __construct() {
  18. $this->makefile_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'makefiles';
  19. }
  20. /**
  21. * Run a given quick-drupal test.
  22. *
  23. * @param $test
  24. * The test makefile to run, as defined by $this->getQuickDrupalTestParameters();
  25. */
  26. private function runQuickDrupalTest($test) {
  27. $config = $this->getQuickDrupalTestParameters($test);
  28. $default_options = array(
  29. 'yes' => NULL,
  30. 'no-server' => NULL,
  31. );
  32. $options = array_merge($config['options'], $default_options);
  33. if (array_key_exists('makefile', $config)) {
  34. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  35. $options['makefile'] = $makefile;
  36. }
  37. $return = !empty($config['fail']) ? self::EXIT_ERROR : self::EXIT_SUCCESS;
  38. $target = UNISH_SANDBOX . '/qd-' . $test;
  39. $options['root'] = $target;
  40. $this->drush('core-quick-drupal', $config['args'], $options, NULL, NULL, $return);
  41. // Use pm-list to determine if all of the correct modules were enabled
  42. if (empty($config['fail'])) {
  43. $this->drush('pm-list', array(), array('root' => $target, 'status' => 'enabled', 'no-core' => NULL, 'pipe' => NULL));
  44. $output = $this->getOutput();
  45. $this->assertEquals($config['expected-modules'], $output, 'quick-drupal included the correct set of modules');
  46. }
  47. }
  48. function testQuickDrupal() {
  49. $this->runQuickDrupalTest('devel');
  50. }
  51. function getQuickDrupalTestParameters($key) {
  52. $tests = array(
  53. 'devel' => array(
  54. 'name' => 'Test quick-drupal with a makefile that downloads devel',
  55. 'makefile' => 'qd-devel.make',
  56. 'expected-modules' => 'devel',
  57. 'args' => array(),
  58. 'options' => array(
  59. 'skip' => NULL, // for speed up enable of devel module.
  60. 'browser' => 0,
  61. 'profile' => UNISH_DRUPAL_MAJOR_VERSION == 6 ? 'standard' : 'testing',
  62. ),
  63. ),
  64. );
  65. return $tests[$key];
  66. }
  67. }