siteUpgradeTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /*
  3. * @file
  4. * Programmatically upgrade a site from Drupal 6 to Druapl 7.
  5. *
  6. * We also implicitly test:
  7. * - pm-download
  8. * - site-install for D6
  9. * - user-create
  10. * - sql-sync
  11. * - updatedb and batch.inc
  12. */
  13. class siteUpgradeCase extends Drush_TestCase {
  14. function testUpgrade() {
  15. $env = 'testupgrade';
  16. $this->setUpDrupal($env, TRUE, '6.x');
  17. $root = $this->sites[$env]['root'];
  18. // Create the alias for D7 site.
  19. $aliases['target'] = array(
  20. 'root' => UNISH_SANDBOX . '/target',
  21. 'uri' => $env,
  22. 'db-url' => UNISH_DB_URL . '/unish_target',
  23. );
  24. $contents = $this->file_aliases($aliases);
  25. $alias_path = "$root/aliases.drushrc.php";
  26. file_put_contents($alias_path, $contents);
  27. // Create a user in D6.
  28. $name = "example";
  29. $options = array(
  30. 'mail' => "example@example.com",
  31. 'password' => 'password',
  32. 'root' => $root,
  33. 'uri' => $env,
  34. );
  35. $this->drush('user-create', array($name), $options);
  36. // Perform the upgrade.
  37. $options = array(
  38. 'yes' => NULL,
  39. 'root' => $root,
  40. 'uri' => $env,
  41. );
  42. $this->drush('site-upgrade', array('@target'), $options);
  43. // Assert that the D7 site bootstraps.
  44. // We don't specify @target alias since that file is in the root of the *source* site.
  45. $options = array(
  46. 'pipe' => NULL,
  47. 'root' => $aliases['target']['root'],
  48. 'uri' => $aliases['target']['uri'],
  49. );
  50. $return = $this->drush('core-status', array('drupal_bootstrap'), $options);
  51. $this->assertEquals('Successful', $this->getOutput(), 'The target site bootstraps successfully');
  52. // Assures that a updatedb and batch updates work properly. See user_update_7001().
  53. $options = array(
  54. 'root' => $aliases['target']['root'],
  55. 'uri' => $aliases['target']['uri'],
  56. );
  57. $eval = "require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');";
  58. $eval .= "\$account = user_load_by_name('example');";
  59. $eval .= "print (string) user_check_password('password', \$account)";
  60. $this->drush('php-eval', array($eval), $options);
  61. $output = $this->getOutput();
  62. $this->assertSame('1', $output, 'User was updated to new password format.');
  63. }
  64. }