public function pmRequestUnitCase::testVersionParserContrib

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

Tests for pm_parse_version() with project versions.

File

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

Namespace

Unish

Class

pmRequestUnitCase
pm testing

Code

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

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

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

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

  $version = '7.x-1.0-beta1+30-dev';
  $version_parts = pm_parse_version($version);
  $this->assertEquals('7.x', $version_parts['drupal_version']);
  $this->assertEquals('1', $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('30', $version_parts['version_offset']);
  $this->assertEquals('1.0-beta1+30-dev', $version_parts['project_version']);

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

  $version = '7.x-1.0+30-dev';
  $version_parts = pm_parse_version($version);
  $this->assertEquals('7.x', $version_parts['drupal_version']);
  $this->assertEquals('1', $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('30', $version_parts['version_offset']);
  $this->assertEquals('1.0+30-dev', $version_parts['project_version']);

  // Since we're not on a bootstrapped site, the version string
  // for the following cases is interpreted as a core version.
  // Tests on a bootstrapped site are in \pmRequestCase::testVersionParser()
  $version = '6.x';
  $version_parts = pm_parse_version($version);
  $this->assertEquals('6.x', $version_parts['drupal_version']);
  $this->assertEquals('', $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']);

  $version = '6.22';
  $version_parts = pm_parse_version($version);
  $this->assertEquals('6.x', $version_parts['drupal_version']);
  $this->assertEquals('', $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']);
}