1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
<?php declare(strict_types=1);
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Test\Util;
use Composer\IO\NullIO;
use Composer\Util\ConfigValidator;
use Composer\Test\TestCase;
/**
* ConfigValidator test case
*/
class ConfigValidatorTest extends TestCase
{
/**
* Test ConfigValidator warns on commit reference
*/
public function testConfigValidatorCommitRefWarning(): void
{
$configValidator = new ConfigValidator(new NullIO());
[, , $warnings] = $configValidator->validate(__DIR__ . '/Fixtures/composer_commit-ref.json');
self::assertContains(
'The package "some/package" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
$warnings
);
}
public function testConfigValidatorWarnsOnScriptDescriptionForNonexistentScript(): void
{
$configValidator = new ConfigValidator(new NullIO());
[, , $warnings] = $configValidator->validate(__DIR__ . '/Fixtures/composer_scripts-descriptions.json');
self::assertContains(
'Description for non-existent script "phpcsxxx" found in "scripts-descriptions"',
$warnings
);
}
public function testConfigValidatorWarnsOnScriptAliasForNonexistentScript(): void
{
$configValidator = new ConfigValidator(new NullIO());
[, , $warnings] = $configValidator->validate(__DIR__ . '/Fixtures/composer_scripts-aliases.json');
self::assertContains(
'Aliases for non-existent script "phpcsxxx" found in "scripts-aliases"',
$warnings
);
}
public function testConfigValidatorWarnsOnUnnecessaryProvideReplace(): void
{
$configValidator = new ConfigValidator(new NullIO());
[, , $warnings] = $configValidator->validate(__DIR__ . '/Fixtures/composer_provide-replace-requirements.json');
self::assertContains(
'The package a/a in require is also listed in provide which satisfies the requirement. Remove it from provide if you wish to install it.',
$warnings
);
self::assertContains(
'The package b/b in require is also listed in replace which satisfies the requirement. Remove it from replace if you wish to install it.',
$warnings
);
self::assertContains(
'The package c/c in require-dev is also listed in provide which satisfies the requirement. Remove it from provide if you wish to install it.',
$warnings
);
}
}
|