Yaffs site version 1.1
[yaffs-website] / vendor / drush / drush / tests / pmRequestTest.php
1 <?php
2
3 namespace Unish;
4
5 /**
6   * @group pm
7   */
8 class pmRequestCase extends CommandUnishTestCase {
9
10   /**
11    * Tests for pm_parse_version() on a bootstrapped site.
12    */
13   public function testVersionParser() {
14     // Setup a Drupal site. Skip install for speed.
15     $sites = $this->setUpDrupal(1, FALSE);
16     $uri = key($sites);
17     $root = $this->webroot();
18
19     $drupal_version = UNISH_DRUPAL_MAJOR_VERSION;
20
21     // Common options for below commands.
22     $options = array(
23       'root' => $root,
24       'uri' => $uri,
25       'format' => 'yaml',
26     );
27
28     // Tests for core versions.
29     $is_core = 1;
30
31     $version = '';
32     $expected = <<<EXPECTED
33 version: ''
34 drupal_version: ${drupal_version}.x
35 project_version: ''
36 version_major: ${drupal_version}
37 version_minor: ''
38 version_patch: ''
39 version_extra: ''
40 version_offset: ''
41 EXPECTED;
42     $this->drush('php-eval', array("return pm_parse_version('${version}', ${is_core})"), $options);
43     $this->assertEquals($expected, $this->getOutput(), 'Core version not provided. Pick version of the bootstrapped site.');
44
45     $version = '5';
46     $expected = <<<EXPECTED
47 version: ''
48 drupal_version: 5.x
49 project_version: ''
50 version_major: '5'
51 version_minor: ''
52 version_patch: ''
53 version_extra: ''
54 version_offset: ''
55 EXPECTED;
56     $this->drush('php-eval', array("return pm_parse_version('${version}', ${is_core})"), $options);
57     $this->assertEquals($expected, $this->getOutput(), 'Core version provided.');
58
59     // Tests for non-core versions.
60     $is_core = 0;
61
62     $version = '';
63     $expected = <<<EXPECTED
64 version: ''
65 drupal_version: ${drupal_version}.x
66 project_version: ''
67 version_major: ${drupal_version}
68 version_minor: ''
69 version_patch: ''
70 version_extra: ''
71 version_offset: ''
72 EXPECTED;
73     $this->drush('php-eval', array("return pm_parse_version('${version}', ${is_core})"), $options);
74     $this->assertEquals($expected, $this->getOutput(), 'Project version not provided. Pick version of the bootstrapped site.');
75
76     $version = '1.0';
77     $expected = <<<EXPECTED
78 version: ${drupal_version}.x-1.0
79 drupal_version: ${drupal_version}.x
80 project_version: '1.0'
81 version_major: '1'
82 version_minor: ''
83 version_patch: '0'
84 version_extra: ''
85 version_offset: ''
86 EXPECTED;
87     $this->drush('php-eval', array("return pm_parse_version('${version}')"), $options);
88     $this->assertEquals($expected, $this->getOutput());
89
90     $version = '1.x';
91     $expected = <<<EXPECTED
92 version: ${drupal_version}.x-1.x-dev
93 drupal_version: ${drupal_version}.x
94 project_version: 1.x-dev
95 version_major: '1'
96 version_minor: ''
97 version_patch: ''
98 version_extra: dev
99 version_offset: ''
100 EXPECTED;
101     $this->drush('php-eval', array("return pm_parse_version('${version}')"), $options);
102     $this->assertEquals($expected, $this->getOutput());
103   }
104 }