diff --git a/tests/Composer/Test/Command/AuditCommandTest.php b/tests/Composer/Test/Command/AuditCommandTest.php index 1b820b479..53041f33d 100644 --- a/tests/Composer/Test/Command/AuditCommandTest.php +++ b/tests/Composer/Test/Command/AuditCommandTest.php @@ -13,6 +13,7 @@ namespace Composer\Test\Command; use Composer\Test\TestCase; +use UnexpectedValueException; class AuditCommandTest extends TestCase { @@ -24,5 +25,20 @@ class AuditCommandTest extends TestCase $appTester->run(['command' => 'audit']); $appTester->assertCommandIsSuccessful(); + self::assertEquals('No packages - skipping audit.', trim($appTester->getDisplay(true))); + } + + public function testErrorAuditingLockFileWhenItIsMissing(): void + { + $this->initTempComposer(); + $this->createInstalledJson([self::getPackage()]); + + $this->expectException(UnexpectedValueException::class); + $this->expectExceptionMessage( + "Valid composer.json and composer.lock files are required to run this command with --locked" + ); + + $appTester = $this->getApplicationTester(); + $appTester->run(['command' => 'audit', '--locked' => true]); } }