1
0
Fork 0

Command tests

pull/10826/head
Jordi Boggiano 2022-06-06 10:48:42 +02:00
parent 8792163676
commit 3c11895c1e
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,57 @@
<?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;
class DiagnoseCommandTest extends TestCase
{
public function testCmdFail(): void
{
$this->initTempComposer(['name' => 'foo/bar', 'description' => 'test pkg']);
$appTester = $this->getApplicationTester();
$appTester->run(['command' => 'diagnose']);
$this->assertSame(1, $appTester->getStatusCode());
$output = $appTester->getDisplay(true);
$this->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);
$this->assertStringContainsString('Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: ', $output);
}
public function testCmdSuccess(): void
{
$this->initTempComposer(['name' => 'foo/bar', 'description' => 'test pkg', 'license' => 'MIT']);
$appTester = $this->getApplicationTester();
$appTester->run(['command' => 'diagnose']);
$appTester->assertCommandIsSuccessful();
$output = $appTester->getDisplay(true);
$this->assertStringContainsString('Checking composer.json: OK', $output);
$this->assertStringContainsString('Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: ', $output);
}
}

View File

@ -28,7 +28,7 @@ class UpdateCommandTest extends TestCase
$appTester = $this->getApplicationTester();
$appTester->run(array_merge(['command' => 'update', '--dry-run' => true], $command));
$this->assertSame(strtr(trim($expected), "\r", ''), strtr(trim($appTester->getDisplay()), "\r", ''));
$this->assertSame(trim($expected), trim($appTester->getDisplay(true)));
}
public function provideUpdates(): \Generator