RuleSetTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. class RuleSetTest extends \PHPUnit_Framework_TestCase
  15. {
  16. public function testAdd()
  17. {
  18. $rules = array(
  19. RuleSet::TYPE_PACKAGE => array(),
  20. RuleSet::TYPE_JOB => array(
  21. new Rule(array(), 'job1', null),
  22. new Rule(array(), 'job2', null),
  23. ),
  24. RuleSet::TYPE_UPDATE => array(
  25. new Rule(array(), 'update1', null),
  26. ),
  27. RuleSet::TYPE_FEATURE => array(),
  28. RuleSet::TYPE_WEAK => array(),
  29. RuleSet::TYPE_LEARNED => array(),
  30. );
  31. $ruleSet = new RuleSet;
  32. $ruleSet->add($rules[RuleSet::TYPE_JOB][0], RuleSet::TYPE_JOB);
  33. $ruleSet->add($rules[RuleSet::TYPE_UPDATE][0], RuleSet::TYPE_UPDATE);
  34. $ruleSet->add($rules[RuleSet::TYPE_JOB][1], RuleSet::TYPE_JOB);
  35. $this->assertEquals($rules, $ruleSet->getRules());
  36. }
  37. }