releaseInfoTest.php

  1. 8.0.x tests/releaseInfoTest.php
  2. 6.x tests/releaseInfoTest.php
  3. 7.x tests/releaseInfoTest.php
  4. 5.x tests/releaseInfoTest.php
  5. master tests/releaseInfoTest.php

Classes

Namesort descending Description
releaseInfoCase pm testing

File

tests/releaseInfoTest.php
View source
  1. <?php
  2. /**
  3. * pm testing
  4. *
  5. * @group pm
  6. */
  7. class releaseInfoCase extends Drush_UnitTestCase {
  8. /*
  9. * Parse Drupal version and release from project specification.
  10. *
  11. * @see pm_parse_project_version().
  12. */
  13. public function testVersionString() {
  14. require_once DRUSH_BASE_PATH . '/commands/pm/pm.drush.inc';
  15. $request_data = pm_parse_project_version(array('devel-6.x-1.18'));
  16. $this->assertArrayHasKey('devel', $request_data);
  17. $this->assertEquals($request_data['devel']['drupal_version'], '6.x');
  18. $this->assertEquals($request_data['devel']['project_version'], '1.18');
  19. }
  20. /*
  21. * Pick right release from the XML (dev, latest published+recommended, ...).
  22. */
  23. public function testReleaseXML() {
  24. _drush_add_commandfiles(array(DRUSH_BASE_PATH . '/commands/pm'));
  25. drush_include_engine('release_info', 'updatexml');
  26. // Use a local, static XML file because live files change over time.
  27. $xml = simplexml_load_file(dirname(__FILE__). '/devel.xml');
  28. // Pick specific release.
  29. $request_data = array(
  30. 'name' => 'devel',
  31. 'drupal_version' => '6.x',
  32. 'project_version' => '1.18',
  33. 'version' => '6.x-1.18',
  34. );
  35. $release = updatexml_parse_release($request_data, $xml);
  36. $this->assertEquals($release['version'], '6.x-1.18');
  37. // Pick latest recommended+published with no further specification.
  38. // 6.x-2.2 is skipped because it is unpublished.
  39. // 6.x-2.2-rc1 is skipped because it is not a stable release.
  40. $request_data = array(
  41. 'name' => 'devel',
  42. 'drupal_version' => '6.x',
  43. );
  44. $release = updatexml_parse_release($request_data, $xml);
  45. $this->assertEquals($release['version'], '6.x-2.1');
  46. // Pick latest from a specific branch.
  47. $request_data = array(
  48. 'name' => 'devel',
  49. 'drupal_version' => '6.x',
  50. 'version' => '6.x-1',
  51. );
  52. $release = updatexml_parse_release($request_data, $xml);
  53. $this->assertEquals($release['version'], '6.x-1.23');
  54. // Pick latest from a different branch.
  55. $request_data = array(
  56. 'name' => 'devel',
  57. 'drupal_version' => '6.x',
  58. 'version' => '6.x-2',
  59. );
  60. $release = updatexml_parse_release($request_data, $xml);
  61. // 6.x-2.2 is skipped because it is unpublished.
  62. // 6.x-2.2-rc1 is skipped because it is not a stable release.
  63. $this->assertEquals($release['version'], '6.x-2.1');
  64. // Pick a -dev release.
  65. $request_data = array(
  66. 'name' => 'devel',
  67. 'drupal_version' => '6.x',
  68. 'version' => '6.x-1.x',
  69. );
  70. $release = updatexml_parse_release($request_data, $xml);
  71. $this->assertEquals($release['version'], '6.x-1.x-dev');
  72. // Test $restrict_to parameter.
  73. $request_data['version'] = '6.x-1';
  74. $release = updatexml_parse_release($request_data, $xml, 'version');
  75. $this->assertEquals($release['version'], '6.x-1.23');
  76. $release = updatexml_parse_release($request_data, $xml, 'dev');
  77. $this->assertEquals($release['version'], '6.x-1.x-dev');
  78. }
  79. }