1
0
Fork 0

Allow --strict-psr in `DumpAutoloadCommand` also with --classmap-authoritative (#11607)

pull/11590/head
Martin Herndl 2023-08-30 21:43:16 +02:00 committed by GitHub
parent 02e4a2d1a3
commit 6fd145f01e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -70,8 +70,8 @@ EOT
$apcuPrefix = $input->getOption('apcu-prefix');
$apcu = $apcuPrefix !== null || $input->getOption('apcu') || $config->get('apcu-autoloader');
if ($input->getOption('strict-psr') && !$optimize) {
throw new \InvalidArgumentException('--strict-psr mode only works with optimized autoloader, use --optimize if you want a strict return value.');
if ($input->getOption('strict-psr') && !$optimize && !$authoritative) {
throw new \InvalidArgumentException('--strict-psr mode only works with optimized autoloader, use --optimize or --classmap-authoritative if you want a strict return value.');
}
if ($authoritative) {

View File

@ -75,12 +75,22 @@ class DumpAutoloadCommandTest extends TestCase
$this->assertMatchesRegularExpression('/Generated optimized autoload files \(authoritative\) containing \d+ classes/', $output);
}
public function testUsingClassmapAuthoritativeAndStrictPsr(): void
{
$appTester = $this->getApplicationTester();
$this->assertSame(0, $appTester->run(['command' => 'dump-autoload', '--classmap-authoritative' => true, '--strict-psr' => true]));
$output = $appTester->getDisplay(true);
$this->assertStringContainsString('Generating optimized autoload files', $output);
$this->assertMatchesRegularExpression('/Generated optimized autoload files \(authoritative\) containing \d+ classes/', $output);
}
public function testStrictPsrDoesNotWorkWithoutOptimizedAutoloader(): void
{
$appTester = $this->getApplicationTester();
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('--strict-psr mode only works with optimized autoloader, use --optimize if you want a strict return value.');
$this->expectExceptionMessage('--strict-psr mode only works with optimized autoloader, use --optimize or --classmap-authoritative if you want a strict return value.');
$appTester->run(['command' => 'dump-autoload', '--strict-psr' => true]);
}