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