From 70ce34d4c3d7528afe435db36be0285bc5438a61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20M=C3=BCller?= <25648755+M-arcus@users.noreply.github.com> Date: Sun, 14 Jun 2026 13:43:03 +0200 Subject: [PATCH 1/2] fix: mock builder handles traits and enums --- guides/development/testing/unit/php-unit.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/guides/development/testing/unit/php-unit.md b/guides/development/testing/unit/php-unit.md index 1a80ef447..1f2b0590d 100644 --- a/guides/development/testing/unit/php-unit.md +++ b/guides/development/testing/unit/php-unit.md @@ -100,7 +100,13 @@ class UsedClassesAvailableTest extends TestCase foreach ($this->getPluginClasses() as $class) { $classRelativePath = str_replace(['.php', '/'], ['', '\\'], $class->getRelativePathname()); - $this->getMockBuilder($namespace . '\\' . $classRelativePath) + /** @var class-string $className */ + $className = $namespace . '\\' . $classRelativePath; + if (trait_exists($className) || enum_exists($className)) { + continue; + } + + $this->getMockBuilder($className) ->disableOriginalConstructor() ->getMock(); } From 78e6c131be9fda1d29d68d9c4aa828f4a2a8f5a1 Mon Sep 17 00:00:00 2001 From: M-arcus <25648755+M-arcus@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:20:12 +0200 Subject: [PATCH 2/2] fix: don't autoload on trait and enum check --- guides/development/testing/unit/php-unit.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/development/testing/unit/php-unit.md b/guides/development/testing/unit/php-unit.md index 1f2b0590d..5b437c96f 100644 --- a/guides/development/testing/unit/php-unit.md +++ b/guides/development/testing/unit/php-unit.md @@ -102,7 +102,7 @@ class UsedClassesAvailableTest extends TestCase /** @var class-string $className */ $className = $namespace . '\\' . $classRelativePath; - if (trait_exists($className) || enum_exists($className)) { + if (trait_exists($className, false) || enum_exists($className, false)) { continue; }