Skip to content

Conversation

@andrewnicols
Copy link
Contributor

@andrewnicols andrewnicols commented Aug 6, 2025

Fixes #205

Blocked by #206 and #207

@codecov
Copy link

codecov bot commented Aug 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.37%. Comparing base (e7b7556) to head (40a9ebf).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #207      +/-   ##
============================================
+ Coverage     98.30%   98.37%   +0.07%     
- Complexity      968     1000      +32     
============================================
  Files            41       42       +1     
  Lines          3006     3140     +134     
============================================
+ Hits           2955     3089     +134     
  Misses           51       51              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andrewnicols andrewnicols marked this pull request as draft August 6, 2025 14:47
@andrewnicols andrewnicols force-pushed the testcaseAttributes branch 2 times, most recently from ea1cd85 to b45d6fc Compare August 6, 2025 15:23
@andrewnicols andrewnicols marked this pull request as ready for review August 6, 2025 15:25
@andrewnicols andrewnicols force-pushed the testcaseAttributes branch 2 times, most recently from 064349d to 52c002b Compare August 7, 2025 01:45
@andrewnicols andrewnicols requested a review from Copilot August 7, 2025 01:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements support for detecting PHP 8.0+ attributes in PHPUnit test case sniffs, specifically adding support for #[DataProvider] and other PHPUnit attributes alongside existing phpdoc-based annotations.

  • Adds a new NamespaceScopeUtil helper class to properly qualify class names considering imports and namespaces
  • Extends PHPUnit sniffs to support both traditional phpdoc comments and modern PHP attributes
  • Creates a shared AbstractTestCaseSniff base class to consolidate common functionality

Reviewed Changes

Copilot reviewed 14 out of 39 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
moodle/Util/NamespaceScopeUtil.php New utility class for qualifying class names within namespace scope
moodle/Util/Attributes.php Enhanced with qualified name support and new helper methods
moodle/Tests/Util/NamespaceScopeUtilTest.php Test coverage for the new namespace utility
moodle/Tests/Util/AttributesTest.php Updated tests for enhanced attribute functionality
moodle/Tests/Sniffs/PHPUnit/fixtures/Provider/attributes_test.php Test fixture for attribute-based data providers
moodle/Tests/Sniffs/PHPUnit/fixtures/Covers/testcasecovers_method_attribute.php Test fixture for method-level coverage attributes
moodle/Tests/Sniffs/PHPUnit/fixtures/Covers/testcasecovers_attribute.php Test fixture for class-level coverage attributes
moodle/Tests/Sniffs/PHPUnit/fixtures/Covers/testcasecovers_abstract.php Test fixture for abstract test classes
moodle/Tests/Sniffs/PHPUnit/TestCaseProviderTest.php Updated test with attribute support cases
moodle/Tests/Sniffs/PHPUnit/TestCaseCoversTest.php Updated test with attribute support cases
moodle/Sniffs/PHPUnit/TestCaseProviderSniff.php Enhanced to detect and validate DataProvider attributes
moodle/Sniffs/PHPUnit/TestCaseCoversSniff.php Enhanced to detect and validate coverage attributes
moodle/Sniffs/PHPUnit/AbstractTestCaseSniff.php New base class for PHPUnit sniffs with shared functionality
CHANGELOG.md Documentation of the changes

@andrewnicols andrewnicols force-pushed the testcaseAttributes branch 3 times, most recently from a29418a to cedfd35 Compare August 13, 2025 04:03
@andrewnicols andrewnicols merged commit c289c43 into moodlehq:main Aug 14, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Teach PHPUnit sniffs to understand Attributes as well of Annotations

1 participant