/** * 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); }
/** * Should this automatic update be permitted? * * @param UpdateInfo $info * @param string $currentVersion * @return bool */ protected function checkVersionSettings(UpdateInfo $info, string $currentVersion) : bool { $state = State::instance(); $nextVersion = $info->getVersion(); $version = new Version($currentVersion); // If this isn't an upgrade at all, don't apply it. if (!$version->isUpgrade($nextVersion)) { return false; } if ($version->isMajorUpgrade($nextVersion)) { return !empty($state->universal['auto-update']['major']); } if ($version->isMinorUpgrade($nextVersion)) { return !empty($state->universal['auto-update']['minor']); } if ($version->isPatchUpgrade($nextVersion)) { return !empty($state->universal['auto-update']['patch']); } return false; }