1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Add support for warnings/infos keys to report more complex information to diverse Composer versions

This commit is contained in:
Jordi Boggiano 2021-11-24 16:00:57 +01:00
parent ebf4cbdc69
commit 7e3626362e
No known key found for this signature in database
GPG key ID: 7BBD42C429EC80BC
2 changed files with 50 additions and 1 deletions

View file

@ -12,6 +12,7 @@
namespace Composer\Test\Util;
use Composer\IO\BufferIO;
use Composer\Util\HttpDownloader;
use PHPUnit\Framework\TestCase;
@ -51,4 +52,32 @@ class HttpDownloaderTest extends TestCase
$this->assertNotEquals(200, $e->getCode());
}
}
public function testOutputWarnings()
{
$io = new BufferIO();
HttpDownloader::outputWarnings($io, '$URL', array());
$this->assertSame('', $io->getOutput());
HttpDownloader::outputWarnings($io, '$URL', array(
'warning' => 'old warning msg',
'warning-versions' => '>=2.0',
'info' => 'old info msg',
'info-versions' => '>=2.0',
'warnings' => array(
array('message' => 'should not appear', 'versions' => '<2.2'),
array('message' => 'visible warning', 'versions' => '>=2.2-dev'),
),
'infos' => array(
array('message' => 'should not appear', 'versions' => '<2.2'),
array('message' => 'visible info', 'versions' => '>=2.2-dev'),
),
));
// the <info> tag are consumed by the OutputFormatter, but not <warning> as that is not a default output format
$this->assertSame('<warning>Warning from $URL: old warning msg</warning>
Info from $URL: old info msg
<warning>Warning from $URL: visible warning</warning>
Info from $URL: visible info
', $io->getOutput());
}
}