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. $this->drush('pm-download', array('devel'), $options);
  26. $this->drush('pm-list', array(), $options + array('no-core' => NULL, 'status' => 'disabled,not installed'));
  27. $out = $this->getOutput();
  28. $list = $this->getOutputAsList();
  29. $this->assertTrue(in_array('devel', $list));
  30. $this->drush('pm-enable', array('devel'), $options_no_pipe);
  31. $output = $this->getOutput();
  32. $this->assertContains('access devel information', $output);
  33. $this->drush('pm-info', array('devel'), $options);
  34. $output = $this->getOutputFromJSON('devel');
  35. $expected = array(
  36. 'extension' => 'devel',
  37. 'project' => 'devel',
  38. 'type' => 'module',
  39. 'title' => 'Devel',
  40. 'status' => 'enabled',
  41. );
  42. foreach ($expected as $key => $value) {
  43. $this->assertEquals($expected[$key], $value);
  44. }
  45. $this->drush('pm-list', array(), $options + array('status' => 'enabled'));
  46. $list = $this->getOutputAsList();
  47. $this->assertTrue(in_array('devel', $list));
  48. // In D7, the testing profile uses 'bartik', whereas in D8, 'classy' is used.
  49. $themeToCheck = UNISH_DRUPAL_MAJOR_VERSION >= 8 ? 'classy' : (UNISH_DRUPAL_MAJOR_VERSION == 7 ? 'bartik' : 'garland');
  50. $this->assertTrue(in_array($themeToCheck, $list), 'Themes are in the pm-list');
  51. if (UNISH_DRUPAL_MAJOR_VERSION <= 7) {
  52. $path = UNISH_DRUPAL_MAJOR_VERSION == 7 ? 'devel/settings' : 'admin/settings/devel';
  53. $this->drush('sql-query', array("SELECT path FROM menu_router WHERE path = '$path';"), array('root' => $this->webroot(), 'uri' => key($sites)));
  54. $list = $this->getOutputAsList();
  55. $this->assertTrue(in_array($path, $list), 'Cache was cleared after modules were enabled');
  56. }
  57. $this->drush('pm-list', array(), $options + array('package' => 'Core'));
  58. $list = $this->getOutputAsList();
  59. $this->assertFalse(in_array('devel', $list), 'Devel is not part of core package');
  60. if (UNISH_DRUPAL_MAJOR_VERSION <= 7) {
  61. $this->drush('pm-disable', array('devel'), $options);
  62. $this->drush('pm-list', array(), $options + array('status' => 'disabled'));
  63. $list = $this->getOutputAsList();
  64. $this->assertTrue(in_array('devel', $list));
  65. }
  66. $this->drush('pm-uninstall', array('devel'), $options);
  67. $this->drush('pm-list', array(), $options + array('status' => 'not installed', 'type' => 'module'));
  68. $list = $this->getOutputAsList();
  69. $this->assertTrue(in_array('devel', $list));
  70. // Test pm-enable is able to download dependencies.
  71. // @todo pathauto has no usable D8 release yet.
  72. // Also, Drupal 6 has no stable releases any longer, so resolve-dependencies are inconvenient to test.
  73. if (UNISH_DRUPAL_MAJOR_VERSION ==7) {
  74. $this->drush('pm-download', array('pathauto'), $options);
  75. $this->drush('pm-enable', array('pathauto'), $options + array('resolve-dependencies' => TRUE));
  76. $this->drush('pm-list', array(), $options + array('status' => 'enabled'));
  77. $list = $this->getOutputAsList();
  78. $this->assertTrue(in_array('token', $list));
  79. // Test that pm-enable downloads missing projects and dependencies.
  80. $this->drush('pm-enable', array('panels'), $options + array('resolve-dependencies' => TRUE));
  81. $this->drush('pm-list', array(), $options + array('status' => 'enabled'));
  82. $list = $this->getOutputAsList();
  83. $this->assertTrue(in_array('ctools', $list));
  84. }
  85. }
  86. }