pmEnDisUnListInfoTest.php

  1. 8.0.x tests/pmEnDisUnListInfoTest.php
  2. 7.x tests/pmEnDisUnListInfoTest.php
  3. master tests/pmEnDisUnListInfoTest.php

Tests for enable, disable, uninstall, pm-list commands.

Namespace

Unish

Classes

Namesort descending Description
EnDisUnListInfoCase @group slow @group pm

File

tests/pmEnDisUnListInfoTest.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Tests for enable, disable, uninstall, pm-list commands.
  5. */
  6. namespace Unish;
  7. /**
  8. * @group slow
  9. * @group pm
  10. */
  11. class EnDisUnListInfoCase extends CommandUnishTestCase {
  12. public function testEnDisUnList() {
  13. $sites = $this->setUpDrupal(1, TRUE);
  14. $options_no_pipe = array(
  15. 'yes' => NULL,
  16. 'root' => $this->webroot(),
  17. 'uri' => key($sites),
  18. 'cache' => NULL,
  19. 'skip' => NULL, // No FirePHP
  20. 'strict' => 0, // Don't validate options
  21. );
  22. $options = $options_no_pipe + array(
  23. 'pipe' => NULL,
  24. );
  25. // Test pm-download downloads a module and pm-list lists it.
  26. $this->drush('pm-download', array('devel'), $options);
  27. $this->drush('pm-list', array(), $options + array('no-core' => NULL, 'status' => 'disabled,not installed'));
  28. $out = $this->getOutput();
  29. $list = $this->getOutputAsList();
  30. $this->assertTrue(in_array('devel', $list));
  31. // Test pm-enable enables a module and shows the permissions it provides.
  32. $this->drush('pm-enable', array('devel'), $options_no_pipe);
  33. $output = $this->getOutput();
  34. $this->assertContains('access devel information', $output);
  35. // Test pm-list shows the module as enabled.
  36. $this->drush('pm-list', array(), $options + array('status' => 'enabled'));
  37. $list = $this->getOutputAsList();
  38. $this->assertTrue(in_array('devel', $list));
  39. // Test pm-info shows some module info.
  40. $this->drush('pm-info', array('devel'), $options);
  41. $output = $this->getOutputFromJSON('devel');
  42. $expected = array(
  43. 'extension' => 'devel',
  44. 'project' => 'devel',
  45. 'type' => 'module',
  46. 'title' => 'Devel',
  47. 'status' => 'enabled',
  48. );
  49. foreach ($expected as $key => $value) {
  50. $this->assertEquals($output->{$key}, $value);
  51. }
  52. // Test pm-projectinfo shows some project info.
  53. $this->drush('pm-projectinfo', array('devel'), $options);
  54. $output = $this->getOutputFromJSON('devel');
  55. $expected = array(
  56. 'label' => 'Devel (devel)',
  57. 'type' => 'module',
  58. 'status' => '1',
  59. );
  60. foreach ($expected as $key => $value) {
  61. $this->assertEquals($output->{$key}, $value);
  62. }
  63. // Test the testing install profile theme is installed.
  64. $themeToCheck = UNISH_DRUPAL_MAJOR_VERSION >= 8 ? 'classy' : (UNISH_DRUPAL_MAJOR_VERSION == 7 ? 'bartik' : 'garland');
  65. $this->assertTrue(in_array($themeToCheck, $list), 'Themes are in the pm-list');
  66. // Test cache was cleared after enabling a module.
  67. $table = UNISH_DRUPAL_MAJOR_VERSION >= 8 ? 'router' : 'menu_router';
  68. $path = UNISH_DRUPAL_MAJOR_VERSION >= 8 ? '/admin/config/development/devel' : (UNISH_DRUPAL_MAJOR_VERSION == 7 ? 'devel/settings' : 'admin/settings/devel');
  69. $this->drush('sql-query', array("SELECT path FROM $table WHERE path = '$path';"), array('root' => $this->webroot(), 'uri' => key($sites)));
  70. $list = $this->getOutputAsList();
  71. $this->assertTrue(in_array($path, $list), 'Cache was cleared after modules were enabled');
  72. // Test pm-list filtering.
  73. $this->drush('pm-list', array(), $options + array('package' => 'Core'));
  74. $list = $this->getOutputAsList();
  75. $this->assertFalse(in_array('devel', $list), 'Devel is not part of core package');
  76. // Test module disabling.
  77. if (UNISH_DRUPAL_MAJOR_VERSION <= 7) {
  78. $this->drush('pm-disable', array('devel'), $options);
  79. $this->drush('pm-list', array(), $options + array('status' => 'disabled'));
  80. $list = $this->getOutputAsList();
  81. $this->assertTrue(in_array('devel', $list));
  82. }
  83. // Test module uninstall.
  84. $this->drush('pm-uninstall', array('devel'), $options);
  85. $this->drush('pm-list', array(), $options + array('status' => 'not installed', 'type' => 'module'));
  86. $list = $this->getOutputAsList();
  87. $this->assertTrue(in_array('devel', $list));
  88. // Test pm-enable is able to download dependencies.
  89. // @todo pathauto has no usable D8 release yet.
  90. if (UNISH_DRUPAL_MAJOR_VERSION <=7) {
  91. $this->drush('pm-download', array('pathauto'), $options);
  92. $this->drush('pm-enable', array('pathauto'), $options + array('resolve-dependencies' => TRUE));
  93. $this->drush('pm-list', array(), $options + array('status' => 'enabled'));
  94. $list = $this->getOutputAsList();
  95. $this->assertTrue(in_array('token', $list));
  96. }
  97. // Test that pm-enable downloads missing projects and dependencies.
  98. $this->drush('pm-enable', array('panels'), $options + array('resolve-dependencies' => TRUE));
  99. $this->drush('pm-list', array(), $options + array('status' => 'enabled'));
  100. $list = $this->getOutputAsList();
  101. $this->assertTrue(in_array('ctools', $list));
  102. // Test that pm-enable downloads missing projects
  103. // and dependencies with project namespace (date:date_popup).
  104. if (UNISH_DRUPAL_MAJOR_VERSION == 7) {
  105. $this->drush('pm-enable', array('date_datepicker_inline'), $options + array('resolve-dependencies' => TRUE));
  106. $this->drush('pm-list', array(), $options + array('status' => 'enabled'));
  107. $list = $this->getOutputAsList();
  108. $this->assertTrue(in_array('date_popup', $list));
  109. }
  110. }
  111. }