Exemplo n.º 1
0
 /**
  * Pick right release from the XML (dev, latest published+recommended, ...).
  */
 public function testReleaseXML()
 {
     _drush_add_commandfiles(array(DRUSH_BASE_PATH . '/commands/pm'));
     $release_info = 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');
     $project_release_info = new \Drush\UpdateService\Project($xml);
     // Pick specific release.
     $release = $project_release_info->getSpecificRelease('6.x-1.18');
     $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.
     $release = $project_release_info->getRecommendedOrSupportedRelease();
     $this->assertEquals('6.x-2.1', $release['version']);
     // Pick latest from a specific branch.
     $release = $project_release_info->getSpecificRelease('6.x-1');
     $this->assertEquals('6.x-1.23', $release['version']);
     // Pick latest from a different branch.
     // 6.x-2.2 is skipped because it is unpublished.
     // 6.x-2.2-rc1 is skipped because it is not a stable release.
     $release = $project_release_info->getSpecificRelease('6.x-2');
     $this->assertEquals('6.x-2.1', $release['version']);
     // Pick a -dev release.
     $release = $project_release_info->getSpecificRelease('6.x-1.x');
     $this->assertEquals('6.x-1.x-dev', $release['version']);
     // Test UpdateServiceProject::getSpecificRelease().
     // Test we get latest release in branch 1.
     $release = $project_release_info->getSpecificRelease('6.x-1');
     $this->assertEquals('6.x-1.23', $release['version']);
     // Test UpdateServiceProject::getDevRelease().
     $release = $project_release_info->getDevRelease();
     $this->assertEquals('6.x-1.x-dev', $release['version']);
 }
Exemplo n.º 2
0
 /**
  * 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']);
 }
Exemplo n.º 3
0
 /**
  * Tests for pm_parse_version() with project versions.
  */
 public function testVersionParserContrib()
 {
     _drush_add_commandfiles(array(DRUSH_BASE_PATH . '/commands/pm'));
     drush_set_option('default-major', UNISH_DRUPAL_MAJOR_VERSION);
     $version = '';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('', $version_parts['version']);
     $this->assertEquals(UNISH_DRUPAL_MAJOR_VERSION . '.x', $version_parts['drupal_version']);
     $this->assertEquals('', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('', $version_parts['project_version']);
     $version = '7';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('', $version_parts['version']);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('', $version_parts['project_version']);
     $version = '7.x';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('', $version_parts['version']);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('', $version_parts['project_version']);
     $version = '7.x-1.0-beta1';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('1', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('0', $version_parts['version_patch']);
     $this->assertEquals('beta1', $version_parts['version_extra']);
     $this->assertEquals('1.0-beta1', $version_parts['project_version']);
     $version = '7.x-1.0-beta1+30-dev';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('1', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('0', $version_parts['version_patch']);
     $this->assertEquals('beta1', $version_parts['version_extra']);
     $this->assertEquals('30', $version_parts['version_offset']);
     $this->assertEquals('1.0-beta1+30-dev', $version_parts['project_version']);
     $version = '7.x-1.0';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('1', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('0', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('1.0', $version_parts['project_version']);
     $version = '7.x-1.0+30-dev';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('1', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('0', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('30', $version_parts['version_offset']);
     $this->assertEquals('1.0+30-dev', $version_parts['project_version']);
     // Since we're not on a bootstrapped site, the version string
     // for the following cases is interpreted as a core version.
     // Tests on a bootstrapped site are in \pmRequestCase::testVersionParser()
     $version = '6.x';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('6.x', $version_parts['drupal_version']);
     $this->assertEquals('', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('', $version_parts['project_version']);
     $version = '6.22';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('6.x', $version_parts['drupal_version']);
     $this->assertEquals('', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('', $version_parts['project_version']);
 }