Example #1
0
 /**
  * @covers \Airship\expand_version()
  */
 public function testExpandVersion()
 {
     $this->assertSame(1000100, \Airship\expand_version('1.0.1'));
     $this->assertSame(1010100, \Airship\expand_version('1.1.1'));
     $this->assertSame(1100100, \Airship\expand_version('1.10.1'));
     $this->assertSame(1009900, \Airship\expand_version('1.0.99'));
 }
Example #2
0
 /**
  *  This is mostly to catch regressions.
  */
 public function testGroupArithmetic()
 {
     $t = \Airship\expand_version('3.45.67');
     $this->assertEquals(Version::getGroup($t, Version::GROUP_MAJOR), 3);
     $this->assertEquals(Version::getGroup($t, Version::GROUP_MINOR), 45);
     $this->assertEquals(Version::getGroup($t, Version::GROUP_PATCH), 67);
     // Let's make sure large major versions don't break
     $u = \Airship\expand_version('125.0.0');
     $this->assertEquals(Version::getGroup($u, Version::GROUP_MAJOR), 125);
     $this->assertEquals(Version::getGroup($u, Version::GROUP_MINOR), 0);
     $this->assertEquals(Version::getGroup($u, Version::GROUP_PATCH), 0);
 }
Example #3
0
 /**
  * Get the expected next version, based on upgrade type.
  *
  *  From '1.4.11':
  *    (self::GROUP_PATCH) -> '1.4.12'
  *    (self::GROUP_MINOR) -> '1.5.0'
  *    (self::GROUP_MAJOR) -> '2.0.0'
  *
  * @param int $type
  * @return string
  */
 public function getUpgrade(int $type = self::GROUP_PATCH) : string
 {
     $value = \Airship\expand_version($this->currentVersion);
     $value += $type;
     $value -= $value % $type;
     return \implode('.', [self::getGroup($value, self::GROUP_MAJOR), self::getGroup($value, self::GROUP_MINOR), self::getGroup($value, self::GROUP_PATCH)]);
 }
Example #4
0
 /**
  * Get the expanded version for this particular update
  *
  * @return int
  */
 public function getVersionExpanded() : int
 {
     return \Airship\expand_version($this->version);
 }