Add more tests and validate that there is only one comma
parent
ca168d478b
commit
4c713978e9
|
@ -233,7 +233,7 @@ class VersionParser
|
|||
$orConstraints = preg_split('{\s*\|\s*}', trim($constraints));
|
||||
$orGroups = array();
|
||||
foreach ($orConstraints as $constraints) {
|
||||
$andConstraints = preg_split('{(?<!as|[=><])\s*[, ]+\s*(?!as)}', $constraints);
|
||||
$andConstraints = preg_split('{(?<!^|as|[=>< ,]) *[, ] *(?!,|as|$)}', $constraints);
|
||||
|
||||
if (count($andConstraints) > 1) {
|
||||
$constraintObjects = array();
|
||||
|
|
|
@ -313,6 +313,10 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
|||
array('>2.0, <=3.0'),
|
||||
array('>2.0 ,<=3.0'),
|
||||
array('>2.0 , <=3.0'),
|
||||
array('>2.0 , <=3.0'),
|
||||
array('> 2.0 <= 3.0'),
|
||||
array('> 2.0 , <= 3.0'),
|
||||
array(' > 2.0 , <= 3.0 '),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -365,6 +369,9 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
|||
return array(
|
||||
'empty ' => array(''),
|
||||
'invalid version' => array('1.0.0-meh'),
|
||||
'operator abuse' => array('>2.0,,<=3.0'),
|
||||
'operator abuse/2' => array('>2.0 ,, <=3.0'),
|
||||
'operator abuse/3' => array('>2.0 || <=3.0'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue