forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreleaseInfoTest.php
95 lines (84 loc) · 3.01 KB
/
releaseInfoTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* @file
* Tests for release_info engine.
*/
namespace Unish;
/**
* pm testing
*
* @group pm
*/
class releaseInfoCase extends UnitUnishTestCase {
/**
* Parse Drupal version and release from project specification.
*
* @see pm_parse_project_version().
*/
public function testVersionString() {
_drush_add_commandfiles(array(DRUSH_BASE_PATH . '/commands/pm'));
$request_data = pm_parse_project_version(array('devel-6.x-1.18'));
$this->assertArrayHasKey('devel', $request_data);
$this->assertEquals('6.x', $request_data['devel']['drupal_version']);
$this->assertEquals('1.18', $request_data['devel']['project_version']);
}
/**
* Pick right release from the XML (dev, latest published+recommended, ...).
*/
public function testReleaseXML() {
_drush_add_commandfiles(array(DRUSH_BASE_PATH . '/commands/pm'));
drush_include_engine('release_info', 'updatexml');
// Use a local, static XML file because live files change over time.
$xml = simplexml_load_file(dirname(__FILE__). '/devel.xml');
// Pick specific release.
$request_data = array(
'name' => 'devel',
'drupal_version' => '6.x',
'project_version' => '1.18',
'version' => '6.x-1.18',
);
$release = updatexml_parse_release($request_data, $xml);
$this->assertEquals('6.x-1.18', $release['version']);
// Pick latest recommended+published with no further specification.
// 6.x-2.2 is skipped because it is unpublished.
// 6.x-2.2-rc1 is skipped because it is not a stable release.
$request_data = array(
'name' => 'devel',
'drupal_version' => '6.x',
);
$release = updatexml_parse_release($request_data, $xml);
$this->assertEquals('6.x-2.1', $release['version']);
// Pick latest from a specific branch.
$request_data = array(
'name' => 'devel',
'drupal_version' => '6.x',
'version' => '6.x-1',
);
$release = updatexml_parse_release($request_data, $xml);
$this->assertEquals('6.x-1.23', $release['version']);
// Pick latest from a different branch.
$request_data = array(
'name' => 'devel',
'drupal_version' => '6.x',
'version' => '6.x-2',
);
$release = updatexml_parse_release($request_data, $xml);
// 6.x-2.2 is skipped because it is unpublished.
// 6.x-2.2-rc1 is skipped because it is not a stable release.
$this->assertEquals('6.x-2.1', $release['version']);
// Pick a -dev release.
$request_data = array(
'name' => 'devel',
'drupal_version' => '6.x',
'version' => '6.x-1.x',
);
$release = updatexml_parse_release($request_data, $xml);
$this->assertEquals('6.x-1.x-dev', $release['version']);
// Test $restrict_to parameter.
$request_data['version'] = '6.x-1';
$release = updatexml_parse_release($request_data, $xml, 'version');
$this->assertEquals('6.x-1.23', $release['version']);
$release = updatexml_parse_release($request_data, $xml, 'dev');
$this->assertEquals('6.x-1.x-dev', $release['version']);
}
}