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
|
<?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\Command;
use Composer\Test\TestCase;
use Composer\Util\Platform;
use PHPUnit\Framework\Attributes\Group;
class DiagnoseCommandTest extends TestCase
{
#[Group('remote')]
public function testCmdFail(): void
{
$this->initTempComposer(['name' => 'foo/bar', 'description' => 'test pkg']);
$appTester = $this->getApplicationTester();
$appTester->run(['command' => 'diagnose']);
if (Platform::getEnv('COMPOSER_LOWEST_DEPS_TEST') === '1') {
self::assertGreaterThanOrEqual(1, $appTester->getStatusCode());
} else {
self::assertSame(1, $appTester->getStatusCode());
}
$output = $appTester->getDisplay(true);
self::assertStringContainsString('Checking composer.json: <warning>WARNING</warning>
<warning>No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.</warning>', $output);
self::assertStringContainsString('Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: ', $output);
}
#[Group('remote')]
public function testCmdSuccess(): void
{
$this->initTempComposer(['name' => 'foo/bar', 'description' => 'test pkg', 'license' => 'MIT']);
$appTester = $this->getApplicationTester();
$appTester->run(['command' => 'diagnose']);
if (Platform::getEnv('COMPOSER_LOWEST_DEPS_TEST') !== '1') {
$appTester->assertCommandIsSuccessful();
}
$output = $appTester->getDisplay(true);
self::assertStringContainsString('Checking composer.json: OK', $output);
self::assertStringContainsString('Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: ', $output);
}
}
|