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