class pmUpdateCode

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


Expanded class hierarchy of pmUpdateCode


Contains filters are case sensitive
Namesort descending Modifiers Type Description
Drush_CommandTestCase::drush function Invoke drush in via execute().
Drush_CommandTestCase::drush_major_version function
Drush_CommandTestCase::execute function Actually runs the command. Does not trap the error stream output as this need PHP 4.3+.
Drush_CommandTestCase::EXIT_ERROR constant
Drush_CommandTestCase::EXIT_SUCCESS constant
Drush_CommandTestCase::file_aliases function
Drush_TestCase::bit_bucket function Borrowed from Drush. Checks operating system and returns supported bit bucket folder.
Drush_TestCase::convert_path function Converts a Windows path (dir1\dir2\dir3) into a Unix path (dir1/dir2/dir3). Also converts a cygwin "drive emulation" path (/cygdrive/c/dir1) into a proper drive path, still with Unix slashes (c:/dir1).
Drush_TestCase::db_url function
Drush_TestCase::directory_cache function
Drush_TestCase::escapeshellarg public static function
Drush_TestCase::fetchInstallDrupal function
Drush_TestCase::getOutput function Accessor for the last output.
Drush_TestCase::getOutputAsList function Accessor for the last output.
Drush_TestCase::get_tar_executable public static function
Drush_TestCase::is_windows public static function
Drush_TestCase::log function Print a log message to the console.
Drush_TestCase::log_level function
Drush_TestCase::randomString public function Helper function to generate a random string of arbitrary length.
Drush_TestCase::setUpBeforeClass public static function Assure that each class starts with an empty sandbox directory and a clean environment -
Drush_TestCase::setUpDrupal function
Drush_TestCase::setUpFreshSandBox public static function Remove any pre-existing sandbox, then create a new one.
Drush_TestCase::tearDownAfterClass public static function Runs after all tests in a class are run. Remove sandbox directory.
Drush_TestCase::webroot function
Drush_TestCase::_escapeshellarg_windows public static function
Drush_TestCase::__construct function
pmUpdateCode::setUp public function Download old core and older contrib releases which will always need updating.
pmUpdateCode::testUpdateCode function


tests/pmUpdateCodeTest.php, line 14
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.

View source
class pmUpdateCode extends Drush_CommandTestCase {

   * Download old core and older contrib releases which will always need updating.
  public function setUp() {
    $sites = $this->setUpDrupal(1, TRUE, '7.0-rc3');
    $options = array(
      'root' => $this->webroot(),
      'uri' => key($sites),
      'yes' => NULL,
      'quiet' => NULL,
      'cache' => NULL,
      'skip' => NULL, // No FirePHP
      'invoke' => NULL, // invoke from script: do not verify options
    $this->drush('pm-download', array('devel-7.x-1.0-rc1,webform-7.x-3.4-beta1'), $options);
    $this->drush('pm-enable', array('menu', 'devel', 'webform'), $options);

  function testUpdateCode() {
    $options = array(
      'root' => $this->webroot(),
      'uri' => key($this->sites), // Have to access class property since $sites in in setUp().
      'yes' => NULL,
      'backup-dir' => UNISH_SANDBOX . '/backups',

    // Try to upgrade a specific module.
    $this->drush('pm-updatecode', array('devel'), $options + array());
    // Assure that devel was upgraded and webform was not.
    $this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
    $all = $this->getOutput();
    $this->assertNotContains('devel', $all);
    $this->assertContains('webform', $all);

    // Lock webform, and update core.
    $this->drush('pm-updatecode', array(), $options + array('lock' => 'webform'));
    $list = $this->getOutputAsList(); // For debugging.
    $this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
    $all = $this->getOutput();
    $this->assertNotContains('drupal', $all, 'Core was updated');
    $this->assertContains('webform', $all, 'Webform was skipped.');

    // Unlock webform, update, and check.
    $this->drush('pm-updatecode', array(), $options + array('unlock' => 'webform', 'no-backup' => NULL));
    $list = $this->getOutputAsList();
    $this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
    $all = $this->getOutput();
    $this->assertNotContains('webform', $all, 'Webform was updated');

    // Verify that we keep backups as instructed.
    $backup_dir = UNISH_SANDBOX . '/backups';
    $Directory = new RecursiveDirectoryIterator($backup_dir);
    $Iterator = new RecursiveIteratorIterator($Directory);
    $found = FALSE;
    foreach ($Iterator as $item) {
      if (basename($item) == 'devel.module') {
        $found = TRUE;
    $this->assertTrue($found, 'Backup exists and contains devel module.');

    $Iterator = new RecursiveIteratorIterator($Directory);
    $found = FALSE;
    foreach ($Iterator as $item) {
      if (basename($item) == 'webform.module') {
        $found = TRUE;
    $this->assertFalse($found, 'Backup exists and does not contain webformmodule.');