ConfigValidatorTest.php 1.4 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\Test\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. list(, , $warnings) = $configValidator->validate(__DIR__ . '/Fixtures/composer_commit-ref.json');
  27. $this->assertContains(
  28. 'The package "some/package" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  29. $warnings
  30. );
  31. }
  32. public function testConfigValidatorWarnsOnScriptDescriptionForNonexistentScript()
  33. {
  34. $configValidator = new ConfigValidator(new NullIO());
  35. list(, , $warnings) = $configValidator->validate(__DIR__ . '/Fixtures/composer_scripts-descriptions.json');
  36. $this->assertContains(
  37. 'Description for non-existent script "phpcsxxx" found in "scripts-descriptions"',
  38. $warnings
  39. );
  40. }
  41. }