forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PmEnDisUnListInfoTest.php
80 lines (67 loc) · 3.49 KB
/
PmEnDisUnListInfoTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* @file
* Tests for enable, disable, uninstall, pm-list commands.
*/
namespace Unish;
use Composer\Semver\Comparator;
/**
* @group slow
* @group pm
*/
class EnDisUnListInfoTest extends CommandUnishTestCase
{
public function testEnDisUnList()
{
$sites = $this->setUpDrupal(1, true);
// Test that pm-list lists uninstalled modules.
$this->drush('pm-list', [], ['no-core' => null, 'status' => 'disabled']);
$out = $this->getOutput();
$this->assertStringContainsString('drush_empty_module', $out);
// Test that pm-install does not install a module if the install
// requirements are not met.
$this->drush('pm-install', ['drush_empty_module'], [], null, null, self::EXIT_ERROR, null, [
'UNISH_FAIL_INSTALL_REQUIREMENTS' => 'drush_empty_module',
]);
$err = $this->getErrorOutput();
$this->assertStringContainsString("Unable to install module 'drush_empty_module' due to unmet requirement(s)", $err);
$this->assertStringContainsString('Primary install requirements not met.', $err);
$this->assertStringContainsString('Secondary install requirements not met.', $err);
$this->drush('pm-list', [], ['no-core' => null, 'status' => 'disabled']);
$out = $this->getOutput();
$this->assertStringContainsString('drush_empty_module', $out);
// Test pm-install enables a module, and pm-list verifies that.
$this->drush('pm-install', ['drush_empty_module']);
$this->drush('pm-list', [], ['status' => 'enabled']);
$out = $this->getOutput();
$this->assertStringContainsString('drush_empty_module', $out);
$this->drush('core:status', [], ['field' => 'drupal-version']);
$drupal_version = $this->getOutputRaw();
// Test the testing install profile theme is installed.
$active_theme = 'stark';
$this->assertStringContainsString($active_theme, $out, 'Themes are in the pm-list');
// Test cache was cleared after enabling a module.
$table = 'router';
$path = '/admin/config/development/drush_empty_module';
$this->drush('sql-query', ["SELECT path FROM $table WHERE path = '$path';"]);
$list = $this->getOutputAsList();
$this->assertTrue(in_array($path, $list), 'Cache was cleared after modules were enabled');
// Test pm-list filtering.
$this->drush('pm-list', [], ['package' => 'Core']);
$out = $this->getOutput();
$this->assertStringNotContainsString('drush_empty_module', $out, 'Drush Empty Module is not part of core package');
// Check output fields in pm-list
$this->drush('pm-list', [], ['fields' => '*', 'format' => 'json']);
$extensionProperties = $this->getOutputFromJSON();
$this->assertTrue(isset($extensionProperties['drush_empty_module']));
$this->assertEquals($extensionProperties['drush_empty_module']['project'], 'drush_empty_module');
$this->assertEquals($extensionProperties['drush_empty_module']['package'], 'Other');
$this->assertEquals($extensionProperties['drush_empty_module']['status'], 'Enabled');
$this->assertEquals($extensionProperties['drush_empty_module']['type'], 'module');
// Test module uninstall.
$this->drush('pm-uninstall', ['drush_empty_module']);
$this->drush('pm-list', [], ['status' => 'disabled', 'type' => 'module']);
$out = $this->getOutput();
$this->assertStringContainsString('drush_empty_module', $out);
}
}