pmUpdateCodeTest.php

  1. 8.0.x tests/pmUpdateCodeTest.php
  2. 6.x tests/pmUpdateCodeTest.php
  3. 7.x tests/pmUpdateCodeTest.php
  4. 4.x tests/pmUpdateCodeTest.php
  5. 5.x tests/pmUpdateCodeTest.php
  6. master tests/pmUpdateCodeTest.php

Prepare a codebase and upgrade it in several stages, exercising updatecode's filters. @todo test security-only once one of these modules or core gets a security release.

Classes

Namesort descending Description
pmUpdateCode

File

tests/pmUpdateCodeTest.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Prepare a codebase and upgrade it in several stages, exercising
  5. * updatecode's filters.
  6. * @todo test security-only once one of these modules or core gets a security release.
  7. */
  8. /*
  9. * @group slow
  10. * @group pm
  11. */
  12. class pmUpdateCode extends Drush_CommandTestCase {
  13. /**
  14. * Download old core and older contrib releases which will always need updating.
  15. */
  16. public function setUp() {
  17. $sites = $this->setUpDrupal(1, TRUE, '7.0-rc3');
  18. $options = array(
  19. 'root' => $this->webroot(),
  20. 'uri' => key($sites),
  21. 'yes' => NULL,
  22. 'quiet' => NULL,
  23. 'cache' => NULL,
  24. 'skip' => NULL, // No FirePHP
  25. 'invoke' => NULL, // invoke from script: do not verify options
  26. );
  27. $this->drush('pm-download', array('devel-7.x-1.0-rc1,webform-7.x-3.4-beta1'), $options);
  28. $this->drush('pm-enable', array('menu', 'devel', 'webform'), $options);
  29. }
  30. function testUpdateCode() {
  31. $options = array(
  32. 'root' => $this->webroot(),
  33. 'uri' => key($this->sites), // Have to access class property since $sites in in setUp().
  34. 'yes' => NULL,
  35. 'backup-dir' => UNISH_SANDBOX . '/backups',
  36. );
  37. // Try to upgrade a specific module.
  38. $this->drush('pm-updatecode', array('devel'), $options + array());
  39. // Assure that devel was upgraded and webform was not.
  40. $this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
  41. $all = $this->getOutput();
  42. $this->assertNotContains('devel', $all);
  43. $this->assertContains('webform', $all);
  44. // Lock webform, and update core.
  45. $this->drush('pm-updatecode', array(), $options + array('lock' => 'webform'));
  46. $list = $this->getOutputAsList(); // For debugging.
  47. $this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
  48. $all = $this->getOutput();
  49. $this->assertNotContains('drupal', $all, 'Core was updated');
  50. $this->assertContains('webform', $all, 'Webform was skipped.');
  51. // Unlock webform, update, and check.
  52. $this->drush('pm-updatecode', array(), $options + array('unlock' => 'webform', 'no-backup' => NULL));
  53. $list = $this->getOutputAsList();
  54. $this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
  55. $all = $this->getOutput();
  56. $this->assertNotContains('webform', $all, 'Webform was updated');
  57. // Verify that we keep backups as instructed.
  58. $backup_dir = UNISH_SANDBOX . '/backups';
  59. $Directory = new RecursiveDirectoryIterator($backup_dir);
  60. $Iterator = new RecursiveIteratorIterator($Directory);
  61. $found = FALSE;
  62. foreach ($Iterator as $item) {
  63. if (basename($item) == 'devel.module') {
  64. $found = TRUE;
  65. break;
  66. }
  67. }
  68. $this->assertTrue($found, 'Backup exists and contains devel module.');
  69. $Iterator = new RecursiveIteratorIterator($Directory);
  70. $found = FALSE;
  71. foreach ($Iterator as $item) {
  72. if (basename($item) == 'webform.module') {
  73. $found = TRUE;
  74. break;
  75. }
  76. }
  77. $this->assertFalse($found, 'Backup exists and does not contain webformmodule.');
  78. }
  79. }