Minor improvements to VersionParser

main
Jordi Boggiano 13 years ago
parent bd45194292
commit da6566b343

@ -49,9 +49,9 @@ class VersionParser
// add version modifiers if a version was matched // add version modifiers if a version was matched
if (isset($index)) { if (isset($index)) {
if (!empty($matches[$index])) { if (!empty($matches[$index])) {
$mod = array('p', 'pl', 'rc'); $mod = array('{^pl?$}', '{^rc$}');
$modNormalized = array('patch', 'patch', 'RC'); $modNormalized = array('patch', 'RC');
$version .= '-'.str_replace($mod, $modNormalized, strtolower($matches[$index])) $version .= '-'.preg_replace($mod, $modNormalized, strtolower($matches[$index]))
. (!empty($matches[$index+1]) ? $matches[$index+1] : ''); . (!empty($matches[$index+1]) ? $matches[$index+1] : '');
} }

@ -35,6 +35,8 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
'parses state' => array('1.0.0RC1dev', '1.0.0.0-RC1-dev'), 'parses state' => array('1.0.0RC1dev', '1.0.0.0-RC1-dev'),
'CI parsing' => array('1.0.0-rC15-dev', '1.0.0.0-RC15-dev'), 'CI parsing' => array('1.0.0-rC15-dev', '1.0.0.0-RC15-dev'),
'delimiters' => array('1.0.0.RC.15-dev', '1.0.0.0-RC15-dev'), 'delimiters' => array('1.0.0.RC.15-dev', '1.0.0.0-RC15-dev'),
'RC uppercase' => array('1.0.0-rc1', '1.0.0.0-RC1'),
'patch replace' => array('1.0.0.pl3-dev', '1.0.0.0-patch3-dev'),
'forces w.x.y.z' => array('1.0-dev', '1.0.0.0-dev'), 'forces w.x.y.z' => array('1.0-dev', '1.0.0.0-dev'),
'forces w.x.y.z' => array('0', '0.0.0.0'), 'forces w.x.y.z' => array('0', '0.0.0.0'),
'parses long' => array('10.4.13-beta', '10.4.13.0-beta'), 'parses long' => array('10.4.13-beta', '10.4.13.0-beta'),

Loading…
Cancel
Save