sqlSyncTest.php

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

Classes

Namesort descending Description
sqlSyncTest

File

tests/sqlSyncTest.php
View source
  1. <?php
  2. /*
  3. * @file
  4. * For now we only test sql-sync in simulated mode.
  5. *
  6. * Future: Using two copies of Drupal, we could test
  7. * overwriting one site with another.
  8. */
  9. class sqlSyncTest extends Drush_TestCase {
  10. /*
  11. * Covers the following responsibilities.
  12. * - A user created on the source site is copied to the destination site.
  13. * - The email address of the copied user is sanitized on the destination site.
  14. *
  15. * General handling of site aliases will be in sitealiasTest.php.
  16. */
  17. public function testLocalSqlSync() {
  18. $this->setUpDrupal('dev', TRUE);
  19. $this->setUpDrupal('stage', TRUE);
  20. $dump_dir = UNISH_SANDBOX . "/dump-dir";
  21. mkdir($dump_dir);
  22. // Create a user in the staging site
  23. $name = 'joe.user';
  24. $mail = "joe.user@myhome.com";
  25. $options = array(
  26. 'root' => $this->sites['stage']['root'],
  27. 'uri' => 'stage',
  28. 'yes' => NULL,
  29. );
  30. $this->drush('user-create', array($name), $options + array('password' => 'password', 'mail' => $mail));
  31. // Copy stage to dev with --sanitize
  32. $sync_options = array(
  33. 'sanitize' => NULL,
  34. 'yes' => NULL,
  35. 'dump-dir' => $dump_dir
  36. );
  37. $this->drush('sql-sync', array('@stage', '@dev'), $sync_options);
  38. // Confirm that the sample user has the correct email address on the staging site
  39. $this->drush('user-information', array($name), $options + array('pipe' => NULL));
  40. $output = $this->getOutput();
  41. $row = str_getcsv($output);
  42. $uid = $row[1];
  43. $this->assertEquals($mail, $row[2], 'email address is unchanged on source site.');
  44. $this->assertEquals($name, $row[0]);
  45. $options = array(
  46. 'root' => $this->sites['dev']['root'],
  47. 'uri' => 'dev',
  48. 'yes' => NULL,
  49. );
  50. // Confirm that the sample user's email address has been sanitized on the dev site
  51. $this->drush('user-information', array($name), $options + array('pipe' => NULL));
  52. $output = $this->getOutput();
  53. $row = str_getcsv($output);
  54. $uid = $row[1];
  55. $this->assertEquals("user+2@localhost", $row[2], 'email address was sanitized on destination site.');
  56. $this->assertEquals($name, $row[0]);
  57. }
  58. }