Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Intervals.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ private static function generateIntervals(ConstraintInterface $constraint, $stop
}
}

$branches['names'] = array_unique($branches['names']);
// reindex, as the array functions above keep the keys and isSubsetOf compares the names by index
$branches['names'] = array_values(array_unique($branches['names']));

if (\count($numericGroups) === 1) {
return array('numeric' => $numericGroups[0], 'branches' => $branches);
Expand Down
18 changes: 18 additions & 0 deletions tests/IntervalsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,24 @@ public static function intervalsProvider()
), 'branches' => array('names' => array('dev-master', 'dev-foo'), 'exclude' => true)),
'!= dev-master, != dev-foo || > 5'
),
'branch names are a list when duplicates are removed' => array(
array('numeric' => array(
array(
'start' => '>= 0.0.0.0-dev',
'end' => '< '.PHP_INT_MAX.'.0.0.0',
),
), 'branches' => array('names' => array('dev-master', 'dev-foo'), 'exclude' => true)),
'!= dev-master, != dev-master, != dev-foo'
),
'branch names are a list when names are dropped by a disjunction' => array(
array('numeric' => array(
array(
'start' => '>= 0.0.0.0-dev',
'end' => '< '.PHP_INT_MAX.'.0.0.0',
),
), 'branches' => array('names' => array('dev-foo'), 'exclude' => true)),
'!= dev-master, != dev-foo || != dev-foo'
),
'conjunctive constraints should be intersected' => array(
array('numeric' => array(
array(
Expand Down
3 changes: 3 additions & 0 deletions tests/SubsetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public static function subsets()
array('<3', '<=3'),
array('= dev-foo', '= dev-foo'),
array('!= dev-foo', '!= dev-foo'),
array('!= dev-foo, != dev-foo, != dev-bar', '!= dev-foo'),
array('!= dev-foo, != dev-bar || != dev-bar', '!= dev-bar'),
array('!= dev-foo, != dev-bar || != dev-bar', '!= dev-foo, != dev-bar || != dev-bar'),
array('< dev-foo', '= dev-foo'), // invalid range matches nothing so is a subset of any other
array('< 0.0.0', '< 0.0.0'), // empty numeric range matches nothing so is a subset of itself
array('< 0.0.0', '^1.0'),
Expand Down