pmUpdateCodeTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. class pmUpdateCode extends Drush_TestCase {
  9. /*
  10. * Download old core and older contrib releases which will always need updating.
  11. */
  12. public function setUp() {
  13. $this->setUpDrupal('dev', TRUE, '7.0-rc3');
  14. $options = array(
  15. 'root' => $this->sites['dev']['root'],
  16. 'uri' => 'dev',
  17. 'yes' => NULL,
  18. 'quiet' => NULL,
  19. );
  20. $this->drush('pm-download', array('devel-7.x-1.0-rc1,webform-7.x-3.4-beta1'), $options);
  21. $this->drush('pm-enable', array('menu', 'devel', 'webform'), $options);
  22. }
  23. function testUpdateCode() {
  24. $options = array(
  25. 'root' => $this->sites['dev']['root'],
  26. 'uri' => 'dev',
  27. 'yes' => NULL,
  28. 'backup-dir' => UNISH_SANDBOX . '/backups',
  29. 'self-update' => 0, // Don't try update Drush.
  30. );
  31. // Try to upgrade a specific module.
  32. $this->drush('pm-updatecode', array('devel'), $options + array());
  33. // Assure that devel was upgraded and webform was not.
  34. $this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
  35. $all = $this->getOutput();
  36. $this->assertNotContains('devel', $all);
  37. $this->assertContains('webform', $all);
  38. // Lock webform, and update core.
  39. $this->drush('pm-updatecode', array(), $options + array('lock' => 'webform'));
  40. $list = $this->getOutputAsList(); // For debugging.
  41. $this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
  42. $all = $this->getOutput();
  43. $this->assertNotContains('drupal', $all, 'Core was updated');
  44. $this->assertContains('webform', $all, 'Webform was skipped.');
  45. // Unlock webform, update, and check.
  46. $this->drush('pm-updatecode', array(), $options + array('unlock' => 'webform', 'no-backup' => NULL));
  47. $list = $this->getOutputAsList();
  48. $this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
  49. $all = $this->getOutput();
  50. $this->assertNotContains('webform', $all, 'Webform was updated');
  51. // Verify that we keep backups as instructed.
  52. $pattern = 'find %s -iname %s';
  53. $backup_dir = UNISH_SANDBOX . '/backups';
  54. $cmd = sprintf($pattern, self::escapeshellarg($backup_dir), escapeshellarg('devel.module'));
  55. $this->execute($cmd);
  56. $output = $this->getOutput();
  57. $this->assertNotEmpty($output);
  58. $cmd = sprintf($pattern, self::escapeshellarg($backup_dir), escapeshellarg('webform.module'));
  59. $this->execute($cmd);
  60. $output = $this->getOutput();
  61. $this->assertEmpty($output);
  62. }
  63. }