mirror of
https://github.com/getgrav/grav.git
synced 2026-06-14 23:31:35 +02:00
Add versionFormatIsNextSignificantRelease and versionFormatIsEqualOrHigher methods
And corresponding tests
This commit is contained in:
@@ -248,6 +248,30 @@ class InstallCommand extends ConsoleCommand
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the passed version information contains next significant release (tilde) operator
|
||||
*
|
||||
* Example: returns true for $version: '~2.0'
|
||||
*
|
||||
* @param $version
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function versionFormatIsNextSignificantRelease($version) {
|
||||
return substr($version, 0, 1) == '~';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the passed version information contains equal or higher operator
|
||||
*
|
||||
* Example: returns true for $version: '>=2.0'
|
||||
*
|
||||
* @param $version
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function versionFormatIsEqualOrHigher($version) {
|
||||
return substr($version, 0, 2) == '>=';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two releases are compatible by next significant release
|
||||
|
||||
@@ -114,6 +114,24 @@ class InstallCommandTest extends \Codeception\TestCase\Test
|
||||
$this->assertTrue(count($dependencies) == 1);
|
||||
$this->assertTrue($dependencies['errors'] == '>=4.0');
|
||||
|
||||
public function testVersionFormatIsNextSignificantRelease()
|
||||
{
|
||||
$this->assertFalse($this->installCommand->versionFormatIsNextSignificantRelease('>=1.0'));
|
||||
$this->assertFalse($this->installCommand->versionFormatIsNextSignificantRelease('>=2.3.4'));
|
||||
$this->assertFalse($this->installCommand->versionFormatIsNextSignificantRelease('>=2.3.x'));
|
||||
$this->assertFalse($this->installCommand->versionFormatIsNextSignificantRelease('1.0'));
|
||||
$this->assertTrue($this->installCommand->versionFormatIsNextSignificantRelease('~2.3.x'));
|
||||
$this->assertTrue($this->installCommand->versionFormatIsNextSignificantRelease('~2.0'));
|
||||
}
|
||||
|
||||
public function testVersionFormatIsEqualOrHigher()
|
||||
{
|
||||
$this->assertTrue($this->installCommand->versionFormatIsEqualOrHigher('>=1.0'));
|
||||
$this->assertTrue($this->installCommand->versionFormatIsEqualOrHigher('>=2.3.4'));
|
||||
$this->assertTrue($this->installCommand->versionFormatIsEqualOrHigher('>=2.3.x'));
|
||||
$this->assertFalse($this->installCommand->versionFormatIsEqualOrHigher('~2.3.x'));
|
||||
$this->assertFalse($this->installCommand->versionFormatIsEqualOrHigher('1.0'));
|
||||
}
|
||||
|
||||
public function testCheckNextSignificantReleasesAreCompatible()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user