feat: support inherited test methods from abstract base classes#352
Merged
feat: support inherited test methods from abstract base classes#352
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #352 +/- ##
==========================================
- Coverage 94.04% 93.88% -0.16%
==========================================
Files 78 80 +2
Lines 2921 3206 +285
Branches 536 620 +84
==========================================
+ Hits 2747 3010 +263
- Misses 156 178 +22
Partials 18 18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e39604f to
929f7ca
Compare
Add ClassRegistry to track class inheritance across files, enabling Test Explorer to discover test methods inherited from abstract parent classes (fixes #277, #164). - Add ClassRegistry with extendsTestCase/resolveInheritedMethods - Extract extends/use-statement resolution in PhpAstNodeWrapper - PHPUnitParser registers all classes and merges inherited methods - TestCollection re-parses child classes when parent file changes - ClassRegistry injected via constructor for proper DI
929f7ca to
a28bc6c
Compare
…olution Add TraitUseParser to parse PHP trait use statements including insteadof and as adaptations. ClassRegistry now resolves trait methods with correct PHP precedence (own > trait > parent) and supports nested trait-uses with cycle detection.
- Merge filterChildrenByKind/filterChildrenByKinds into single method accepting string | string[] - Add trait support to children getter for consistency - Remove unused variable assignment in TestCollection.change() - Extract resolveTraitMethods into collectTraitMethods, applyInsteadofAdaptations, applyAliasAdaptations - Convert PHPUnitParser.classRegistry to constructor injection, remove setClassRegistry - Simplify ProblemMatcher: remove redundant cache.get after set, merge has+get in handleFinished, use direct comparison in isFault - Extract extractTraitAndMethod in TraitUseParser to eliminate duplication - Unify classFQN split logic in NamespaceDefinitionBuilder
- Extract deleteById() in TestDefinitionIndex to share deletion logic - Extract getMessage()/formatTestName() in OutputFormatter base class - PrettyPrinter/CollisionPrinter use shared base class methods - Replace array allocation with direct === comparison in utils.ts and PestV1Fixer - Update extension.test.ts expected counts for inherited test methods (+4)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ClassRegistryto track class inheritance info across files, enabling Test Explorer to discover test methods inherited from abstract parent classesextendsandusestatements inPhpAstNodeWrapperto build fully-qualified parent class namesPHPUnitParsernow registers all classes (including abstract) and merges inherited methods into concrete subclassesTestCollectionre-parses child classes when a parent file changes, handling cross-file parse orderClassRegistryis injected via constructor for proper DIFixes #277, #164
Test plan
ClassRegistryunit tests: register, extendsTestCase, resolveInheritedMethods, circular detection, deleteByUri, getChildClassesPHPUnitParsertests: inherited methods discovered, own+inherited merged, use-statement FQN resolution, fully-qualified extends, child override precedenceConcreteFromAbstractTest(no own methods) andConcreteWithOwnTest(own + inherited) discovered in Test Explorertsc --noEmitzero errorsbiome checkzero errors