commandSpecificTest.php

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

Namespace

Unish

Classes

Namesort descending Description
commandSpecificCase Assure that context API behaves as designed. Mostly implicitly tested, but we do have some edges that need explicit testing. *

File

tests/commandSpecificTest.php
View source
  1. <?php
  2. namespace Unish;
  3. /**
  4. * Assure that context API behaves as designed. Mostly implicitly tested, but we
  5. * do have some edges that need explicit testing.
  6. *
  7. * @see drush/includes/context.inc.
  8. *
  9. * @group base
  10. */
  11. class commandSpecificCase extends CommandUnishTestCase {
  12. /**
  13. * Try to write a tiny drushrc.php to each place that drush checks. Also
  14. * write a sites/dev/aliases.drushrc.php file to the sandbox.
  15. */
  16. function setUp() {
  17. parent::setUp();
  18. $path = UNISH_SANDBOX . '/aliases.drushrc.php';
  19. $aliases['site1'] = array(
  20. 'root' => UNISH_SANDBOX,
  21. 'uri' => 'site1.com',
  22. 'source-command-specific' => array(
  23. 'core-rsync' => array(
  24. 'exclude-paths' => 'excluded_by_source',
  25. ),
  26. ),
  27. 'target-command-specific' => array(
  28. 'core-rsync' => array(
  29. 'exclude-paths' => 'excluded_by_target',
  30. ),
  31. ),
  32. 'path-aliases' => array(
  33. '%files' => 'sites/default/files',
  34. ),
  35. );
  36. $contents = $this->unish_file_aliases($aliases);
  37. $return = file_put_contents($path, $contents);
  38. }
  39. function testCommandSpecific() {
  40. $options = array(
  41. 'alias-path' => UNISH_SANDBOX,
  42. 'simulate' => NULL,
  43. 'include-vcs' => NULL,
  44. );
  45. $this->drush('core-rsync', array('/tmp', '@site1'), $options, NULL, NULL, self::EXIT_SUCCESS, '2>&1');
  46. $output = trim($this->getOutput());
  47. $this->assertContains('excluded_by_target', $output);
  48. $this->drush('core-rsync', array('@site1', '/tmp'), $options, NULL, NULL, self::EXIT_SUCCESS, '2>&1');
  49. $output = trim($this->getOutput());
  50. $this->assertContains('excluded_by_source', $output);
  51. $this->drush('core-rsync', array('@site1', '@site1'), $options, NULL, NULL, self::EXIT_SUCCESS, '2>&1');
  52. $output = trim($this->getOutput());
  53. $this->assertContains('excluded_by_target', $output);
  54. // Now do that all again with 'exclude-files'
  55. $options['exclude-files'] = NULL;
  56. $this->drush('core-rsync', array('/tmp', '@site1'), $options, NULL, NULL, self::EXIT_SUCCESS, '2>&1');
  57. $output = trim($this->getOutput());
  58. $this->assertContains('sites/default/files', $output);
  59. $this->assertContains('excluded_by_target', $output);
  60. $this->assertNotContains('include-vcs', $output);
  61. $this->assertNotContains('exclude-paths', $output);
  62. $this->assertNotContains('exclude-files-processed', $output);
  63. $this->drush('core-rsync', array('@site1', '/tmp'), $options, NULL, NULL, self::EXIT_SUCCESS, '2>&1');
  64. $output = trim($this->getOutput());
  65. $this->assertContains('sites/default/files', $output);
  66. // This one does not work. @see drush_sitealias_evaluate_path
  67. // $this->assertContains('excluded_by_source', $output);
  68. $this->assertNotContains('include-vcs', $output);
  69. $this->assertNotContains('exclude-paths', $output);
  70. $this->assertNotContains('exclude-files-processed', $output);
  71. $this->drush('core-rsync', array('@site1', '@site1'), $options, NULL, NULL, self::EXIT_SUCCESS, '2>&1');
  72. $output = trim($this->getOutput());
  73. $this->assertContains('sites/default/files', $output);
  74. $this->assertContains('excluded_by_target', $output);
  75. $this->assertNotContains('include-vcs', $output);
  76. $this->assertNotContains('exclude-paths', $output);
  77. $this->assertNotContains('exclude-files-processed', $output);
  78. }
  79. }