mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Moving rule iteration logic to a separate RuleSet and RuleSetIterator class
This commit is contained in:
parent
26d62640a7
commit
bc672deb32
5 changed files with 452 additions and 114 deletions
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Test\DependencyResolver;
|
||||
|
||||
use Composer\DependencyResolver\Rule;
|
||||
use Composer\DependencyResolver\RuleSet;
|
||||
use Composer\DependencyResolver\RuleSetIterator;
|
||||
|
||||
class ResultSetIteratorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $rules;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->rules = array(
|
||||
RuleSet::TYPE_JOB => array(
|
||||
new Rule(array(), 'job1', null),
|
||||
new Rule(array(), 'job2', null),
|
||||
),
|
||||
RuleSet::TYPE_UPDATE => array(
|
||||
new Rule(array(), 'update1', null),
|
||||
),
|
||||
RuleSet::TYPE_PACKAGE => array(),
|
||||
);
|
||||
}
|
||||
|
||||
public function testForeach()
|
||||
{
|
||||
$ruleSetIterator = new RuleSetIterator($this->rules);
|
||||
|
||||
$result = array();
|
||||
foreach ($ruleSetIterator as $rule)
|
||||
{
|
||||
$result[] = $rule;
|
||||
}
|
||||
|
||||
$expected = array(
|
||||
$this->rules[RuleSet::TYPE_JOB][0],
|
||||
$this->rules[RuleSet::TYPE_JOB][1],
|
||||
$this->rules[RuleSet::TYPE_UPDATE][0],
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue