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

Hierarchy

Expanded class hierarchy of pmUpdateCode

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
Drush_TestCase::create_node_types_php function
Drush_TestCase::drush function Invoke drush in via execute().
Drush_TestCase::drush_major_version function
Drush_TestCase::escapeshellarg public static function
Drush_TestCase::execute function Actually runs the command. Does not trap the error stream output as this need PHP 4.3+.
Drush_TestCase::EXIT_ERROR constant
Drush_TestCase::EXIT_SUCCESS constant
Drush_TestCase::file_aliases function
Drush_TestCase::file_delete_recursive function Same code as drush_delete_dir().
Drush_TestCase::getOutput function Accessor for the last output.
Drush_TestCase::getOutputAsList function Accessor for the last output.
Drush_TestCase::is_windows public static function
Drush_TestCase::setUpBeforeClass public static function Assure that each class starts with an empty sandbox directory and a clean environment - http://drupal.org/node/1103568.
Drush_TestCase::setUpDrupal function
Drush_TestCase::tearDownAfterClass public static function Runs after each test case. Remove sandbox directory.
Drush_TestCase::_escapeshellarg_windows public static function
Drush_TestCase::__construct function
pmUpdateCode::setUp public function
pmUpdateCode::testUpdateCode function

File

tests/pmUpdateCodeTest.php, line 10
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_TestCase {

  /*
   * Download old core and older contrib releases which will always need updating.
   */
  public function setUp() {
    $this->setUpDrupal('dev', TRUE, '7.0-rc3');
    $options = array(
      'root' => $this->sites['dev']['root'],
      'uri' => 'dev',
      'yes' => NULL,
      'quiet' => NULL,
    );
    $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->sites['dev']['root'],
      'uri' => 'dev',
      'yes' => NULL,
      'backup-dir' => UNISH_SANDBOX . '/backups',
      'self-update' => 0, // Don't try update Drush.
    );

    // 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.
    $pattern = 'find %s -iname %s';
    $backup_dir = UNISH_SANDBOX . '/backups';
    $cmd = sprintf($pattern, self::escapeshellarg($backup_dir), escapeshellarg('devel.module'));
    $this->execute($cmd);
    $output = $this->getOutput();
    $this->assertNotEmpty($output);

    $cmd = sprintf($pattern, self::escapeshellarg($backup_dir), escapeshellarg('webform.module'));
    $this->execute($cmd);
    $output = $this->getOutput();
    $this->assertEmpty($output);
  }
}