Allow --strict-psr in `DumpAutoloadCommand` also with --classmap-authoritative (#11607)
parent
02e4a2d1a3
commit
6fd145f01e
|
@ -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) {
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue