TestCase.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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;
  12. use Composer\Package\Version\VersionParser;
  13. use Composer\Package\MemoryPackage;
  14. use Composer\Package\LinkConstraint\VersionConstraint;
  15. abstract class TestCase extends \PHPUnit_Framework_TestCase
  16. {
  17. private static $versionParser;
  18. public static function setUpBeforeClass()
  19. {
  20. if (!self::$versionParser) {
  21. self::$versionParser = new VersionParser();
  22. }
  23. }
  24. protected function getVersionConstraint($operator, $version)
  25. {
  26. return new VersionConstraint(
  27. $operator,
  28. self::$versionParser->normalize($version)
  29. );
  30. }
  31. protected function getPackage($name, $version)
  32. {
  33. $normVersion = self::$versionParser->normalize($version);
  34. return new MemoryPackage($name, $normVersion, $version);
  35. }
  36. }