BUGFIX #5073: Fixed CMS version indicator for alpha and beta versions.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@99789 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-02-24 02:50:47 +00:00
parent a11effb33a
commit 6b1f258c44
2 changed files with 34 additions and 14 deletions

View File

@ -1090,19 +1090,8 @@ JS;
$sapphireVersionFile = file_get_contents(BASE_PATH . '/sapphire/silverstripe_version');
$cmsVersionFile = file_get_contents(BASE_PATH . '/cms/silverstripe_version');
if(strstr($sapphireVersionFile, "/sapphire/trunk")) {
$sapphireVersion = "trunk";
} else {
preg_match("/sapphire\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $sapphireVersionFile, $matches);
$sapphireVersion = ($matches) ? $matches[1] : null;
}
if(strstr($cmsVersionFile, "/cms/trunk")) {
$cmsVersion = "trunk";
} else {
preg_match("/cms\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $cmsVersionFile, $matches);
$cmsVersion = ($matches) ? $matches[1] : null;
}
$sapphireVersion = $this->versionFromVersionFile($sapphireVersionFile);
$cmsVersion = $this->versionFromVersionFile($cmsVersionFile);
if($sapphireVersion == $cmsVersion) {
return $sapphireVersion;
@ -1111,6 +1100,18 @@ JS;
}
}
/**
* Return the version from the content of a silverstripe_version file
*/
public function versionFromVersionFile($fileContent) {
if(preg_match('/\/trunk\/silverstripe_version/', $fileContent)) {
return "trunk";
} else {
preg_match("/\/(?:branches|tags\/rc|tags\/beta|tags\/alpha|tags)\/([A-Za-z0-9._-]+)\/silverstripe_version/", $fileContent, $matches);
return ($matches) ? $matches[1] : null;
}
}
/**
* @return array
*/

View File

@ -14,6 +14,25 @@ class LeftAndMainTest extends FunctionalTest {
CMSMenu::populate_menu();
}
/**
* Test that CMS versions can be interpreted appropriately
*/
public function testCMSVersion() {
$l = new LeftAndMain();
$this->assertEquals("2.4", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/cms/branches/2.4/silverstripe_version $'));
$this->assertEquals("2.2.0", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/cms/tags/2.2.0/silverstripe_version $'));
$this->assertEquals("trunk", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/cms/trunk/silverstripe_version $'));
$this->assertEquals("2.4.0-alpha1", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/cms/tags/alpha/2.4.0-alpha1/silverstripe_version $'));
$this->assertEquals("2.4.0-beta1", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/cms/tags/beta/2.4.0-beta1/silverstripe_version $'));
$this->assertEquals("2.4.0-rc1", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/cms/tags/rc/2.4.0-rc1/silverstripe_version $'));
}
/**
* Check that all subclasses of leftandmain can be accessed
*/