Add versionFormatIsNextSignificantRelease and versionFormatIsEqualOrHigher methods

And corresponding tests
This commit is contained in:
Flavio Copes
2016-02-17 14:22:59 +01:00
parent b331758d9c
commit 5cdc10075a
2 changed files with 42 additions and 0 deletions

View File

@@ -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

View File

@@ -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()
{