5 * Tests for enable, disable, uninstall, pm-list commands.
14 class EnDisUnListInfoCase extends CommandUnishTestCase {
16 public function testEnDisUnList() {
17 $sites = $this->setUpDrupal(1, TRUE);
18 $options_no_pipe = array(
20 'root' => $this->webroot(),
23 'skip' => NULL, // No FirePHP
24 'strict' => 0, // Don't validate options
26 $options = $options_no_pipe + array(
30 // Test pm-download downloads a module and pm-list lists it.
31 $this->drush('pm-download', array('devel'), $options);
32 $this->drush('pm-list', array(), $options + array('no-core' => NULL, 'status' => 'disabled,not installed'));
33 $out = $this->getOutput();
34 $list = $this->getOutputAsList();
35 $this->assertTrue(in_array('devel', $list));
37 // Test pm-enable enables a module and shows the permissions it provides.
38 $this->drush('pm-enable', array('devel'), $options_no_pipe);
39 $output = $this->getOutput();
40 $this->assertContains('access devel information', $output);
42 // Test pm-list shows the module as enabled.
43 $this->drush('pm-list', array(), $options + array('status' => 'enabled'));
44 $list = $this->getOutputAsList();
45 $this->assertTrue(in_array('devel', $list));
47 // Test pm-info shows some module info.
48 $this->drush('pm-info', array('devel'), $options);
49 $output = $this->getOutputFromJSON('devel');
51 'extension' => 'devel',
55 'status' => 'enabled',
57 foreach ($expected as $key => $value) {
58 $this->assertEquals($output->{$key}, $value);
61 // Test pm-projectinfo shows some project info.
62 $this->drush('pm-projectinfo', array('devel'), $options);
63 $output = $this->getOutputFromJSON('devel');
65 'label' => 'Devel (devel)',
69 foreach ($expected as $key => $value) {
70 $this->assertEquals($output->{$key}, $value);
73 // Test the testing install profile theme is installed.
74 $themeToCheck = UNISH_DRUPAL_MAJOR_VERSION >= 8 ? 'classy' : (UNISH_DRUPAL_MAJOR_VERSION == 7 ? 'bartik' : 'garland');
75 $this->assertTrue(in_array($themeToCheck, $list), 'Themes are in the pm-list');
77 // Test cache was cleared after enabling a module.
78 $table = UNISH_DRUPAL_MAJOR_VERSION >= 8 ? 'router' : 'menu_router';
79 $path = UNISH_DRUPAL_MAJOR_VERSION >= 8 ? '/admin/config/development/devel' : (UNISH_DRUPAL_MAJOR_VERSION == 7 ? 'devel/settings' : 'admin/settings/devel');
80 $this->drush('sql-query', array("SELECT path FROM $table WHERE path = '$path';"), array('root' => $this->webroot(), 'uri' => key($sites)));
81 $list = $this->getOutputAsList();
82 $this->assertTrue(in_array($path, $list), 'Cache was cleared after modules were enabled');
84 // Test pm-list filtering.
85 $this->drush('pm-list', array(), $options + array('package' => 'Core'));
86 $list = $this->getOutputAsList();
87 $this->assertFalse(in_array('devel', $list), 'Devel is not part of core package');
89 // Test module disabling.
90 if (UNISH_DRUPAL_MAJOR_VERSION <= 7) {
91 $this->drush('pm-disable', array('devel'), $options);
92 $this->drush('pm-list', array(), $options + array('status' => 'disabled'));
93 $list = $this->getOutputAsList();
94 $this->assertTrue(in_array('devel', $list));
97 // Test module uninstall.
98 $this->drush('pm-uninstall', array('devel'), $options);
99 $this->drush('pm-list', array(), $options + array('status' => 'not installed', 'type' => 'module'));
100 $list = $this->getOutputAsList();
101 $this->assertTrue(in_array('devel', $list));
103 // Test pm-enable is able to download dependencies.
104 // @todo pathauto has no usable D8 release yet.
105 // Also, Drupal 6 has no stable releases any longer, so resolve-dependencies are inconvenient to test.
106 if (UNISH_DRUPAL_MAJOR_VERSION ==7) {
107 $this->drush('pm-download', array('pathauto'), $options);
108 $this->drush('pm-enable', array('pathauto'), $options + array('resolve-dependencies' => TRUE));
109 $this->drush('pm-list', array(), $options + array('status' => 'enabled'));
110 $list = $this->getOutputAsList();
111 $this->assertTrue(in_array('token', $list));
114 if (UNISH_DRUPAL_MAJOR_VERSION !=6) {
115 // Test that pm-enable downloads missing projects and dependencies.
116 $this->drush('pm-enable', array('panels'), $options + array('resolve-dependencies' => TRUE));
117 $this->drush('pm-list', array(), $options + array('status' => 'enabled'));
118 $list = $this->getOutputAsList();
119 $this->assertTrue(in_array('ctools', $list));
122 // Test that pm-enable downloads missing projects
123 // and dependencies with project namespace (date:date_popup).
124 if (UNISH_DRUPAL_MAJOR_VERSION == 7) {
125 $this->drush('pm-enable', array('date_datepicker_inline'), $options + array('resolve-dependencies' => TRUE));
126 $this->drush('pm-list', array(), $options + array('status' => 'enabled'));
127 $list = $this->getOutputAsList();
128 $this->assertTrue(in_array('date_popup', $list));