MatchNoneConstraintTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /*
  3. * This file is part of composer/semver.
  4. *
  5. * (c) Composer <https://github.com/composer>
  6. *
  7. * For the full copyright and license information, please view
  8. * the LICENSE file that was distributed with this source code.
  9. */
  10. namespace Composer\Semver\Constraint;
  11. use PHPUnit\Framework\TestCase;
  12. class MatchNoneConstraintTest extends TestCase
  13. {
  14. /**
  15. * @var MatchNoneConstraint
  16. */
  17. protected $matchNoneConstraint;
  18. protected function setUp()
  19. {
  20. $this->matchNoneConstraint = new MatchNoneConstraint();
  21. }
  22. public function testMatches()
  23. {
  24. $this->assertFalse($this->matchNoneConstraint->matches(new Constraint('==', '1.1')));
  25. $this->assertFalse($this->matchNoneConstraint->matches(new Constraint('!=', '1.1')));
  26. $this->assertFalse($this->matchNoneConstraint->matches(new Constraint('==', 'dev-foo')));
  27. $this->assertFalse($this->matchNoneConstraint->matches(new Constraint('!=', 'dev-foo')));
  28. }
  29. public function testGetPrettyString()
  30. {
  31. $expectedString = 'pretty-string';
  32. $this->matchNoneConstraint->setPrettyString($expectedString);
  33. $result = $this->matchNoneConstraint->getPrettyString();
  34. $this->assertSame($expectedString, $result);
  35. $expectedString = '[]';
  36. $this->matchNoneConstraint->setPrettyString(null);
  37. $result = $this->matchNoneConstraint->getPrettyString();
  38. $this->assertSame($expectedString, $result);
  39. }
  40. }