From 9956a257ad99d2edffc1fa908d3d3e5461f522e6 Mon Sep 17 00:00:00 2001 From: PrinsFrank <25006490+PrinsFrank@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:34:02 +0200 Subject: [PATCH] Add test case for current strictPSR scenario --- tests/ClassMapGeneratorTest.php | 12 ++++++++++++ .../psrViolations/ClassWithIncorrectSubNamespace.php | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 tests/Fixtures/psrViolations/ClassWithIncorrectSubNamespace.php diff --git a/tests/ClassMapGeneratorTest.php b/tests/ClassMapGeneratorTest.php index 393a69e..6e4e5ca 100644 --- a/tests/ClassMapGeneratorTest.php +++ b/tests/ClassMapGeneratorTest.php @@ -240,6 +240,18 @@ public function testCreateMapDoesNotHitRegexBacktraceLimit(): void self::assertEqualsNormalized($expected, $result); } + public function testGetPSR4Violations(): void + { + $this->generator->scanPaths(__DIR__ . '/Fixtures/psrViolations', null, 'psr-4', 'ExpectedNamespace\\'); + $classMap = $this->generator->getClassMap(); + static::assertSame( + [ + 'Class ExpectedNamespace\UnexpectedSubNamespace\ClassWithIncorrectSubNamespace located in ./tests/Fixtures/psrViolations/ClassWithIncorrectSubNamespace.php does not comply with psr-4 autoloading standard. Skipping.', + ], + $classMap->getPsrViolations() + ); + } + /** * @param array $expected * @param array $actual diff --git a/tests/Fixtures/psrViolations/ClassWithIncorrectSubNamespace.php b/tests/Fixtures/psrViolations/ClassWithIncorrectSubNamespace.php new file mode 100644 index 0000000..03f7025 --- /dev/null +++ b/tests/Fixtures/psrViolations/ClassWithIncorrectSubNamespace.php @@ -0,0 +1,5 @@ +