public function pmRequestUnitCase::testVersionParserCore

8.0.x pmRequestUnitTest.php public pmRequestUnitCase::testVersionParserCore()
7.x pmRequestUnitTest.php public pmRequestUnitCase::testVersionParserCore()
master pmRequestUnitTest.php public pmRequestUnitCase::testVersionParserCore()

Tests for pm_parse_version() with drupal version scheme for core.

File

tests/pmRequestUnitTest.php, line 80
Tests for pm parsers.

Namespace

Unish

Class

pmRequestUnitCase
pm testing

Code

public function testVersionParserCore() {
  _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, TRUE);
  $this->assertEquals('', $version_parts['version']);
  $this->assertEquals(UNISH_DRUPAL_MAJOR_VERSION . '.x', $version_parts['drupal_version']);
  $this->assertEquals(UNISH_DRUPAL_MAJOR_VERSION, $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']);

  // We use version 5 in these tests to avoid false positives from
  // pm_parse_version(), in case it was picking drush's default-major.

  $version = '5';
  $version_parts = pm_parse_version($version, TRUE);
  $this->assertEquals('', $version_parts['version']);
  $this->assertEquals('5.x', $version_parts['drupal_version']);
  $this->assertEquals('', $version_parts['project_version']);
  $this->assertEquals('5', $version_parts['version_major']);
  $this->assertEquals('', $version_parts['version_minor']);
  $this->assertEquals('', $version_parts['version_patch']);
  $this->assertEquals('', $version_parts['version_extra']);

  $version = '5.x';
  $version_parts = pm_parse_version($version, TRUE);
  $this->assertEquals('5.x-dev', $version_parts['version']);
  $this->assertEquals('5.x', $version_parts['drupal_version']);
  $this->assertEquals('5', $version_parts['version_major']);
  $this->assertEquals('', $version_parts['version_minor']);
  $this->assertEquals('', $version_parts['version_patch']);
  $this->assertEquals('dev', $version_parts['version_extra']);
  $this->assertEquals('5.x-dev', $version_parts['project_version']);

  $version = '5.x-dev';
  $version_parts = pm_parse_version($version, TRUE);
  $this->assertEquals('5.x-dev', $version_parts['version']);
  $this->assertEquals('5.x', $version_parts['drupal_version']);
  $this->assertEquals('5', $version_parts['version_major']);
  $this->assertEquals('', $version_parts['version_minor']);
  $this->assertEquals('', $version_parts['version_patch']);
  $this->assertEquals('dev', $version_parts['version_extra']);
  $this->assertEquals('5.x-dev', $version_parts['project_version']);

  $version = '5.0';
  $version_parts = pm_parse_version($version, TRUE);
  $this->assertEquals('5.0', $version_parts['version']);
  $this->assertEquals('5.x', $version_parts['drupal_version']);
  $this->assertEquals('5', $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('5.0', $version_parts['project_version']);

  $version = '5.0-beta1';
  $version_parts = pm_parse_version($version, TRUE);
  $this->assertEquals('5.0-beta1', $version_parts['version']);
  $this->assertEquals('5.x', $version_parts['drupal_version']);
  $this->assertEquals('5', $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('5.0-beta1', $version_parts['project_version']);
}