Yaffs site version 1.1
[yaffs-website] / vendor / drush / drush / tests / pmEnDisUnListInfoTest.php
1 <?php
2
3 /**
4  * @file
5  *   Tests for enable, disable, uninstall, pm-list commands.
6  */
7
8 namespace Unish;
9
10 /**
11  *  @group slow
12  *  @group pm
13  */
14 class EnDisUnListInfoCase extends CommandUnishTestCase {
15
16   public function testEnDisUnList() {
17     $sites = $this->setUpDrupal(1, TRUE);
18     $options_no_pipe = array(
19       'yes' => NULL,
20       'root' => $this->webroot(),
21       'uri' => key($sites),
22       'cache' => NULL,
23       'skip' => NULL, // No FirePHP
24       'strict' => 0, // Don't validate options
25     );
26     $options = $options_no_pipe + array(
27       'pipe' => NULL,
28     );
29
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));
36
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);
41
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));
46
47     // Test pm-info shows some module info.
48     $this->drush('pm-info', array('devel'), $options);
49     $output = $this->getOutputFromJSON('devel');
50     $expected = array(
51       'extension' => 'devel',
52       'project' => 'devel',
53       'type' => 'module',
54       'title' => 'Devel',
55       'status' => 'enabled',
56     );
57     foreach ($expected as $key => $value) {
58       $this->assertEquals($output->{$key}, $value);
59     }
60
61     // Test pm-projectinfo shows some project info.
62     $this->drush('pm-projectinfo', array('devel'), $options);
63     $output = $this->getOutputFromJSON('devel');
64     $expected = array(
65       'label' => 'Devel (devel)',
66       'type' => 'module',
67       'status' => '1',
68     );
69     foreach ($expected as $key => $value) {
70       $this->assertEquals($output->{$key}, $value);
71     }
72
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');
76
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');
83
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');
88
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));
95     }
96
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));
102
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));
112     }
113
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));
120     }
121
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));
129     }
130
131   }
132 }