diff --git a/tests/Composer/Test/Command/DumpAutoloadCommandTest.php b/tests/Composer/Test/Command/DumpAutoloadCommandTest.php index 3d5e5b67f..6ac3ce5db 100644 --- a/tests/Composer/Test/Command/DumpAutoloadCommandTest.php +++ b/tests/Composer/Test/Command/DumpAutoloadCommandTest.php @@ -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', '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();