From 359cb1427afee373ea9ff00f8aea148fdd6ec9ed Mon Sep 17 00:00:00 2001 From: Thomas Portelange Date: Sat, 29 Jul 2023 08:13:45 +0200 Subject: [PATCH] BUG include silverstripe core files into roots --- src/Core/Manifest/ClassManifest.php | 5 +++++ tests/php/Core/ClassInfoTest.php | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Core/Manifest/ClassManifest.php b/src/Core/Manifest/ClassManifest.php index 9d406620dfe..0e2887635ab 100644 --- a/src/Core/Manifest/ClassManifest.php +++ b/src/Core/Manifest/ClassManifest.php @@ -650,6 +650,11 @@ public function handleFile($basename, $pathname, $includeTests) } $this->children[$lowerAncestor][$lowerClassName] = $className; } + + // If the class extends a core class, add class to roots + if (strpos($ancestor, 'SilverStripe\\Control') === 0) { + $this->roots[$lowerAncestor] = $ancestor; + } } else { $this->roots[$lowerClassName] = $className; } diff --git a/tests/php/Core/ClassInfoTest.php b/tests/php/Core/ClassInfoTest.php index a1d353483cf..7528c3f3661 100644 --- a/tests/php/Core/ClassInfoTest.php +++ b/tests/php/Core/ClassInfoTest.php @@ -87,6 +87,14 @@ public function testSubclassesFor() $subclassesWithoutBase, ClassInfo::subclassesFor('silverstripe\\core\\tests\\classinfotest\\baseclass', false) ); + + // Check that core classes are present (eg: Email subclasses) + $emailClasses = ClassInfo::subclassesFor(\SilverStripe\Control\Email\Email::class); + $this->assertArrayHasKey( + 'silverstripe\\control\\tests\\email\\emailtest\\emailsubclass', + $emailClasses, + 'It contains : ' . json_encode($emailClasses) + ); } public function testClassName()