RuleSetIteratorTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Test\DependencyResolver;
  12. use Composer\DependencyResolver\Rule;
  13. use Composer\DependencyResolver\RuleSet;
  14. use Composer\DependencyResolver\RuleSetIterator;
  15. class ResultSetIteratorTest extends \PHPUnit_Framework_TestCase
  16. {
  17. protected $rules;
  18. protected function setUp()
  19. {
  20. $this->rules = array(
  21. RuleSet::TYPE_JOB => array(
  22. new Rule(array(), 'job1', null),
  23. new Rule(array(), 'job2', null),
  24. ),
  25. RuleSet::TYPE_UPDATE => array(
  26. new Rule(array(), 'update1', null),
  27. ),
  28. RuleSet::TYPE_PACKAGE => array(),
  29. );
  30. }
  31. public function testForeach()
  32. {
  33. $ruleSetIterator = new RuleSetIterator($this->rules);
  34. $result = array();
  35. foreach ($ruleSetIterator as $rule)
  36. {
  37. $result[] = $rule;
  38. }
  39. $expected = array(
  40. $this->rules[RuleSet::TYPE_JOB][0],
  41. $this->rules[RuleSet::TYPE_JOB][1],
  42. $this->rules[RuleSet::TYPE_UPDATE][0],
  43. );
  44. $this->assertEquals($expected, $result);
  45. }
  46. }