Rules of type feature are no longer needed
parent
69b55f12ae
commit
15f43571b9
|
@ -20,13 +20,11 @@ class RuleSet implements \IteratorAggregate, \Countable
|
||||||
// highest priority => lowest number
|
// highest priority => lowest number
|
||||||
const TYPE_PACKAGE = 0;
|
const TYPE_PACKAGE = 0;
|
||||||
const TYPE_JOB = 1;
|
const TYPE_JOB = 1;
|
||||||
const TYPE_FEATURE = 3;
|
|
||||||
const TYPE_LEARNED = 4;
|
const TYPE_LEARNED = 4;
|
||||||
|
|
||||||
protected static $types = array(
|
protected static $types = array(
|
||||||
-1 => 'UNKNOWN',
|
-1 => 'UNKNOWN',
|
||||||
self::TYPE_PACKAGE => 'PACKAGE',
|
self::TYPE_PACKAGE => 'PACKAGE',
|
||||||
self::TYPE_FEATURE => 'FEATURE',
|
|
||||||
self::TYPE_JOB => 'JOB',
|
self::TYPE_JOB => 'JOB',
|
||||||
self::TYPE_LEARNED => 'LEARNED',
|
self::TYPE_LEARNED => 'LEARNED',
|
||||||
);
|
);
|
||||||
|
|
|
@ -427,7 +427,7 @@ class Solver
|
||||||
|
|
||||||
// push all of our rules (can only be feature or job rules)
|
// push all of our rules (can only be feature or job rules)
|
||||||
// asserting this literal on the problem stack
|
// asserting this literal on the problem stack
|
||||||
foreach ($this->rules->getIteratorFor(array(RuleSet::TYPE_JOB, RuleSet::TYPE_FEATURE)) as $assertRule) {
|
foreach ($this->rules->getIteratorFor(RuleSet::TYPE_JOB) as $assertRule) {
|
||||||
if ($assertRule->isDisabled() || !$assertRule->isAssertion() || $assertRule->isWeak()) {
|
if ($assertRule->isDisabled() || !$assertRule->isAssertion() || $assertRule->isWeak()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ResultSetIteratorTest extends \PHPUnit_Framework_TestCase
|
||||||
new Rule(array(), 'job1', null),
|
new Rule(array(), 'job1', null),
|
||||||
new Rule(array(), 'job2', null),
|
new Rule(array(), 'job2', null),
|
||||||
),
|
),
|
||||||
RuleSet::TYPE_FEATURE => array(
|
RuleSet::TYPE_LEARNED => array(
|
||||||
new Rule(array(), 'update1', null),
|
new Rule(array(), 'update1', null),
|
||||||
),
|
),
|
||||||
RuleSet::TYPE_PACKAGE => array(),
|
RuleSet::TYPE_PACKAGE => array(),
|
||||||
|
@ -46,7 +46,7 @@ class ResultSetIteratorTest extends \PHPUnit_Framework_TestCase
|
||||||
$expected = array(
|
$expected = array(
|
||||||
$this->rules[RuleSet::TYPE_JOB][0],
|
$this->rules[RuleSet::TYPE_JOB][0],
|
||||||
$this->rules[RuleSet::TYPE_JOB][1],
|
$this->rules[RuleSet::TYPE_JOB][1],
|
||||||
$this->rules[RuleSet::TYPE_FEATURE][0],
|
$this->rules[RuleSet::TYPE_LEARNED][0],
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
@ -64,7 +64,7 @@ class ResultSetIteratorTest extends \PHPUnit_Framework_TestCase
|
||||||
$expected = array(
|
$expected = array(
|
||||||
RuleSet::TYPE_JOB,
|
RuleSet::TYPE_JOB,
|
||||||
RuleSet::TYPE_JOB,
|
RuleSet::TYPE_JOB,
|
||||||
RuleSet::TYPE_FEATURE,
|
RuleSet::TYPE_LEARNED,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
|
@ -27,16 +27,15 @@ class RuleSetTest extends TestCase
|
||||||
new Rule(array(), 'job1', null),
|
new Rule(array(), 'job1', null),
|
||||||
new Rule(array(), 'job2', null),
|
new Rule(array(), 'job2', null),
|
||||||
),
|
),
|
||||||
RuleSet::TYPE_FEATURE => array(
|
RuleSet::TYPE_LEARNED => array(
|
||||||
new Rule(array(), 'update1', null),
|
new Rule(array(), 'update1', null),
|
||||||
),
|
),
|
||||||
RuleSet::TYPE_LEARNED => array(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$ruleSet = new RuleSet;
|
$ruleSet = new RuleSet;
|
||||||
|
|
||||||
$ruleSet->add($rules[RuleSet::TYPE_JOB][0], RuleSet::TYPE_JOB);
|
$ruleSet->add($rules[RuleSet::TYPE_JOB][0], RuleSet::TYPE_JOB);
|
||||||
$ruleSet->add($rules[RuleSet::TYPE_FEATURE][0], RuleSet::TYPE_FEATURE);
|
$ruleSet->add($rules[RuleSet::TYPE_LEARNED][0], RuleSet::TYPE_LEARNED);
|
||||||
$ruleSet->add($rules[RuleSet::TYPE_JOB][1], RuleSet::TYPE_JOB);
|
$ruleSet->add($rules[RuleSet::TYPE_JOB][1], RuleSet::TYPE_JOB);
|
||||||
|
|
||||||
$this->assertEquals($rules, $ruleSet->getRules());
|
$this->assertEquals($rules, $ruleSet->getRules());
|
||||||
|
@ -79,7 +78,7 @@ class RuleSetTest extends TestCase
|
||||||
$rule1 = new Rule(array(), 'job1', null);
|
$rule1 = new Rule(array(), 'job1', null);
|
||||||
$rule2 = new Rule(array(), 'job1', null);
|
$rule2 = new Rule(array(), 'job1', null);
|
||||||
$ruleSet->add($rule1, RuleSet::TYPE_JOB);
|
$ruleSet->add($rule1, RuleSet::TYPE_JOB);
|
||||||
$ruleSet->add($rule2, RuleSet::TYPE_FEATURE);
|
$ruleSet->add($rule2, RuleSet::TYPE_LEARNED);
|
||||||
|
|
||||||
$iterator = $ruleSet->getIterator();
|
$iterator = $ruleSet->getIterator();
|
||||||
|
|
||||||
|
@ -95,9 +94,9 @@ class RuleSetTest extends TestCase
|
||||||
$rule2 = new Rule(array(), 'job1', null);
|
$rule2 = new Rule(array(), 'job1', null);
|
||||||
|
|
||||||
$ruleSet->add($rule1, RuleSet::TYPE_JOB);
|
$ruleSet->add($rule1, RuleSet::TYPE_JOB);
|
||||||
$ruleSet->add($rule2, RuleSet::TYPE_FEATURE);
|
$ruleSet->add($rule2, RuleSet::TYPE_LEARNED);
|
||||||
|
|
||||||
$iterator = $ruleSet->getIteratorFor(RuleSet::TYPE_FEATURE);
|
$iterator = $ruleSet->getIteratorFor(RuleSet::TYPE_LEARNED);
|
||||||
|
|
||||||
$this->assertSame($rule2, $iterator->current());
|
$this->assertSame($rule2, $iterator->current());
|
||||||
}
|
}
|
||||||
|
@ -109,7 +108,7 @@ class RuleSetTest extends TestCase
|
||||||
$rule2 = new Rule(array(), 'job1', null);
|
$rule2 = new Rule(array(), 'job1', null);
|
||||||
|
|
||||||
$ruleSet->add($rule1, RuleSet::TYPE_JOB);
|
$ruleSet->add($rule1, RuleSet::TYPE_JOB);
|
||||||
$ruleSet->add($rule2, RuleSet::TYPE_FEATURE);
|
$ruleSet->add($rule2, RuleSet::TYPE_LEARNED);
|
||||||
|
|
||||||
$iterator = $ruleSet->getIteratorWithout(RuleSet::TYPE_JOB);
|
$iterator = $ruleSet->getIteratorWithout(RuleSet::TYPE_JOB);
|
||||||
|
|
||||||
|
@ -141,7 +140,7 @@ class RuleSetTest extends TestCase
|
||||||
->method('equal')
|
->method('equal')
|
||||||
->will($this->returnValue(false));
|
->will($this->returnValue(false));
|
||||||
|
|
||||||
$ruleSet->add($rule, RuleSet::TYPE_FEATURE);
|
$ruleSet->add($rule, RuleSet::TYPE_LEARNED);
|
||||||
|
|
||||||
$this->assertTrue($ruleSet->containsEqual($rule));
|
$this->assertTrue($ruleSet->containsEqual($rule));
|
||||||
$this->assertFalse($ruleSet->containsEqual($rule2));
|
$this->assertFalse($ruleSet->containsEqual($rule2));
|
||||||
|
@ -154,9 +153,9 @@ class RuleSetTest extends TestCase
|
||||||
$literal = new Literal($this->getPackage('foo', '2.1'), true);
|
$literal = new Literal($this->getPackage('foo', '2.1'), true);
|
||||||
$rule = new Rule(array($literal), 'job1', null);
|
$rule = new Rule(array($literal), 'job1', null);
|
||||||
|
|
||||||
$ruleSet->add($rule, RuleSet::TYPE_FEATURE);
|
$ruleSet->add($rule, RuleSet::TYPE_JOB);
|
||||||
|
|
||||||
$this->assertContains('FEATURE : (+foo-2.1.0.0)', $ruleSet->__toString());
|
$this->assertContains('JOB : (+foo-2.1.0.0)', $ruleSet->__toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRuleMock()
|
private function getRuleMock()
|
||||||
|
|
Loading…
Reference in New Issue