ConfigValidatorTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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\Util;
  12. use Composer\IO\NullIO;
  13. use Composer\Util\ConfigValidator;
  14. use Composer\TestCase;
  15. /**
  16. * ConfigValidator test case
  17. */
  18. class ConfigValidatorTest extends TestCase
  19. {
  20. /**
  21. * Test ConfigValidator warns on commit reference
  22. */
  23. public function testConfigValidatorCommitRefWarning()
  24. {
  25. $configValidator = new ConfigValidator(new NullIO());
  26. $reflection = new \ReflectionClass(get_class($configValidator));
  27. $method = $reflection->getMethod('checkForCommitReferences');
  28. $warnings = $reflection->getProperty('warnings');
  29. $method->setAccessible(true);
  30. $warnings->setAccessible(true);
  31. $this->assertEquals(0, count($warnings->getValue($configValidator)));
  32. $method->invokeArgs($configValidator, array(
  33. array(
  34. 'some-package' => 'dev-master#62c4da6',
  35. 'another-package' => '^1.0.0'
  36. )
  37. ));
  38. $this->assertEquals(1, count($warnings->getValue($configValidator)));
  39. }
  40. }