public function pmRequestUnitCase::testVersionParserCoreSemVer

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

Tests for pm_parse_version() with semantic versioning.

File

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

Namespace

Unish

Class

pmRequestUnitCase
pm testing

Code

public function testVersionParserCoreSemVer() {
  _drush_add_commandfiles(array(DRUSH_BASE_PATH . '/commands/pm'));

  drush_set_option('default-major', UNISH_DRUPAL_MAJOR_VERSION);

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

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

  $version = '8.0.0-beta3+252-dev';
  $version_parts = pm_parse_version($version, TRUE);
  $this->assertEquals('8.0.0-beta3+252-dev', $version_parts['version']);
  $this->assertEquals('8.x', $version_parts['drupal_version']);
  $this->assertEquals('8', $version_parts['version_major']);
  $this->assertEquals('0', $version_parts['version_minor']);
  $this->assertEquals('0', $version_parts['version_patch']);
  $this->assertEquals('beta3', $version_parts['version_extra']);
  $this->assertEquals('252', $version_parts['version_offset']);
  $this->assertEquals('8.0.0-beta3+252-dev', $version_parts['project_version']);

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

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