1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Add test case for DumpAutoloadCommand with failing --strict-psr check (#11606)

This commit is contained in:
Martin Herndl 2023-08-30 21:42:45 +02:00 committed by GitHub
parent db53c65986
commit 02e4a2d1a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,6 +47,24 @@ class DumpAutoloadCommandTest extends TestCase
$this->assertMatchesRegularExpression('/Generated optimized autoload files containing \d+ classes/', $output);
}
public function testFailsUsingStrictPsrIfClassMapViolationsAreFound(): void
{
$dir = $this->initTempComposer([
'autoload' => [
'psr-4' => [
'Application\\' => 'src',
]
]
]);
mkdir($dir . '/src/');
file_put_contents($dir . '/src/Foo.php', '<?php namespace Application\Src; class Foo {}');
$appTester = $this->getApplicationTester();
$this->assertSame(1, $appTester->run(['command' => 'dump-autoload', '--optimize' => true, '--strict-psr' => true]));
$output = $appTester->getDisplay(true);
$this->assertMatchesRegularExpression('/Class Application\\\Src\\\Foo located in .*? does not comply with psr-4 autoloading standard. Skipping./', $output);
}
public function testUsingClassmapAuthoritative(): void
{
$appTester = $this->getApplicationTester();