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

Tests for release_info engine.

Classes

Namesort descending Description
releaseInfoCase pm testing

File

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