public function releaseInfoCase::testReleaseXML

8.0.x releaseInfoTest.php public releaseInfoCase::testReleaseXML()
6.x releaseInfoTest.php public releaseInfoCase::testReleaseXML()
7.x releaseInfoTest.php public releaseInfoCase::testReleaseXML()
5.x releaseInfoTest.php public releaseInfoCase::testReleaseXML()
master releaseInfoTest.php public releaseInfoCase::testReleaseXML()

File

tests/releaseInfoTest.php, line 26

Class

releaseInfoCase
pm testing

Code

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($release['version'], '6.x-1.18');

  // 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($release['version'], '6.x-2.1');

  // 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($release['version'], '6.x-1.23');

  // 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($release['version'], '6.x-2.1');

  // 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($release['version'], '6.x-1.x-dev');

  // Test $restrict_to parameter.
  $request_data['version'] = '6.x-1';
  $release = updatexml_parse_release($request_data, $xml, 'version');
  $this->assertEquals($release['version'], '6.x-1.23');
  $release = updatexml_parse_release($request_data, $xml, 'dev');
  $this->assertEquals($release['version'], '6.x-1.x-dev');
}