pmRequestTest.php

  1. 8.0.x tests/pmRequestTest.php
  2. 7.x tests/pmRequestTest.php
  3. master tests/pmRequestTest.php

Namespace

Unish

Classes

Namesort descending Description
pmRequestCase @group pm

File

tests/pmRequestTest.php
View source
  1. <?php
  2. namespace Unish;
  3. /**
  4. * @group pm
  5. */
  6. class pmRequestCase extends CommandUnishTestCase {
  7. /**
  8. * Tests for pm_parse_version() on a bootstrapped site.
  9. */
  10. public function testVersionParser() {
  11. // Setup a Drupal site. Skip install for speed.
  12. $sites = $this->setUpDrupal(1, FALSE);
  13. $uri = key($sites);
  14. $root = $this->webroot();
  15. $drupal_version = UNISH_DRUPAL_MAJOR_VERSION;
  16. // Common options for below commands.
  17. $options = array(
  18. 'root' => $root,
  19. 'uri' => $uri,
  20. 'format' => 'yaml',
  21. );
  22. // Tests for core versions.
  23. $is_core = 1;
  24. $version = '';
  25. $expected = <<<EXPECTED
  26. version: ''
  27. drupal_version: ${drupal_version}.x
  28. project_version: ''
  29. version_major: ${drupal_version}
  30. version_minor: ''
  31. version_patch: ''
  32. version_extra: ''
  33. version_offset: ''
  34. EXPECTED;
  35. $this->drush('php-eval', array("return pm_parse_version('${version}', ${is_core})"), $options);
  36. $this->assertEquals($expected, $this->getOutput(), 'Core version not provided. Pick version of the bootstrapped site.');
  37. $version = '5';
  38. $expected = <<<EXPECTED
  39. version: ''
  40. drupal_version: 5.x
  41. project_version: ''
  42. version_major: '5'
  43. version_minor: ''
  44. version_patch: ''
  45. version_extra: ''
  46. version_offset: ''
  47. EXPECTED;
  48. $this->drush('php-eval', array("return pm_parse_version('${version}', ${is_core})"), $options);
  49. $this->assertEquals($expected, $this->getOutput(), 'Core version provided.');
  50. // Tests for non-core versions.
  51. $is_core = 0;
  52. $version = '';
  53. $expected = <<<EXPECTED
  54. version: ''
  55. drupal_version: ${drupal_version}.x
  56. project_version: ''
  57. version_major: ${drupal_version}
  58. version_minor: ''
  59. version_patch: ''
  60. version_extra: ''
  61. version_offset: ''
  62. EXPECTED;
  63. $this->drush('php-eval', array("return pm_parse_version('${version}', ${is_core})"), $options);
  64. $this->assertEquals($expected, $this->getOutput(), 'Project version not provided. Pick version of the bootstrapped site.');
  65. $version = '1.0';
  66. $expected = <<<EXPECTED
  67. version: ${drupal_version}.x-1.0
  68. drupal_version: ${drupal_version}.x
  69. project_version: '1.0'
  70. version_major: '1'
  71. version_minor: ''
  72. version_patch: '0'
  73. version_extra: ''
  74. version_offset: ''
  75. EXPECTED;
  76. $this->drush('php-eval', array("return pm_parse_version('${version}')"), $options);
  77. $this->assertEquals($expected, $this->getOutput());
  78. $version = '1.x';
  79. $expected = <<<EXPECTED
  80. version: ${drupal_version}.x-1.x-dev
  81. drupal_version: ${drupal_version}.x
  82. project_version: 1.x-dev
  83. version_major: '1'
  84. version_minor: ''
  85. version_patch: ''
  86. version_extra: dev
  87. version_offset: ''
  88. EXPECTED;
  89. $this->drush('php-eval', array("return pm_parse_version('${version}')"), $options);
  90. $this->assertEquals($expected, $this->getOutput());
  91. }
  92. }