archiveDumpTest.php

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

Classes

Namesort descending Description
archiveDumpCase

File

tests/archiveDumpTest.php
View source
  1. <?php
  2. /*
  3. * @file
  4. * Tests for archive.drush.inc
  5. */
  6. class archiveDumpCase extends Drush_TestCase {
  7. /*
  8. * Test dump and extraction.
  9. */
  10. public function testArchiveDump() {
  11. $env = 'testarchivedump';
  12. $this->setUpDrupal($env, TRUE, '6');
  13. $root = $this->sites[$env]['root'];
  14. $docroot = 'web';
  15. // Create the alias for D7 site.
  16. $aliases['archivedump'] = array(
  17. 'root' => UNISH_SANDBOX . '/' . $docroot,
  18. 'uri' => $env,
  19. );
  20. $contents = $this->file_aliases($aliases);
  21. $alias_path = "$root/aliases.drushrc.php";
  22. file_put_contents($alias_path, $contents);
  23. $name = "example";
  24. $dump_dest = "dump.tar.gz";
  25. $options = array(
  26. 'root' => $root,
  27. 'uri' => $env,
  28. 'yes' => NULL,
  29. 'destination' => 'dump.tar.gz',
  30. );
  31. $this->drush('archive-dump', array('@archivedump'), $options);
  32. $exec = sprintf('file %s/%s', UNISH_SANDBOX, $dump_dest);
  33. $this->execute($exec);
  34. $output = $this->getOutput();
  35. $expected = UNISH_SANDBOX . "/dump.tar.gz: gzip compressed data, from Unix";
  36. $this->assertEquals($expected, $output);
  37. // Untar it, make sure it looks right.
  38. $exec = sprintf('tar -xzf %s/%s', UNISH_SANDBOX, $dump_dest);
  39. $untar_dest = UNISH_SANDBOX . '/untar';
  40. $exec = sprintf('mkdir %s && cd %s && tar xzf %s/%s', $untar_dest, $untar_dest, UNISH_SANDBOX, $dump_dest);
  41. $this->execute($exec);
  42. $this->execute(sprintf('head %s/unish_%s.sql | grep "MySQL dump"', $untar_dest, $env));
  43. $this->execute('test -f ' . $untar_dest . '/MANIFEST.ini');
  44. $this->execute('test -d ' . $untar_dest . '/' . $docroot);
  45. }
  46. }