feat(form): Add InputWeek class for HTML <input type="week"> element with attributes and rendering capabilities.#19
Conversation
…ent with attributes and rendering capabilities.
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds a new InputWeek form element class implementing HTML Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 63 66 +3
===========================================
Files 50 51 +1
Lines 133 139 +6
===========================================
+ Hits 133 139 +6 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@tests/Form/InputWeekTest.php`:
- Around line 32-601: The test class InputWeekTest has many near-duplicate tests
(e.g., testRenderWithDir & testRenderWithDirUsingEnum, testRenderWithLang &
testRenderWithLangUsingEnum, testRenderWithRole & testRenderWithRoleUsingEnum,
testRenderWithTranslate & testRenderWithTranslateUsingEnum, autocomplete
variants, attribute/data/aria pairs, etc.); collapse each duplicated pair/group
into a single parameterized test that accepts input name, expected attribute
string and the setter call variant, and add a corresponding data provider method
that returns arrays of (label, setter-argument, expected-html) entries; annotate
the consolidated test methods with `@dataProvider`, update assertions to use the
passed expected string, and remove the original individual test methods (keep
their assertions preserved in the data provider rows) so InputWeekTest uses
providers and reduces public method count while retaining coverage.
- Around line 515-524: The test calls the method with incorrect casing: replace
the lowercase call tabindex() in testRenderWithTabindex() with the actual trait
method name tabIndex() so the line
InputWeek::tag()->id('inputweek-')->tabindex(1)->render() becomes
InputWeek::tag()->id('inputweek-')->tabIndex(1)->render(); this aligns the test
with the defined method tabIndex() and resolves the PHPStan/mutation test
failure.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
CHANGELOG.mdsrc/Form/InputWeek.phptests/Form/InputWeekTest.php
🧰 Additional context used
🧬 Code graph analysis (1)
tests/Form/InputWeekTest.php (1)
src/Form/InputWeek.php (1)
InputWeek(51-96)
🪛 GitHub Check: mutation / PHP 8.5-ubuntu-latest
tests/Form/InputWeekTest.php
[failure] 521-521:
Call to method UIAwesome\Html\Form\InputWeek::tabIndex() with incorrect case: tabindex
🪛 GitHub Check: phpstan / PHP 8.5-ubuntu-latest
tests/Form/InputWeekTest.php
[failure] 521-521:
Call to method UIAwesome\Html\Form\InputWeek::tabIndex() with incorrect case: tabindex
🪛 PHPMD (2.15.0)
tests/Form/InputWeekTest.php
[warning] 32-601: The class InputWeekTest has 50 public methods and attributes. Consider reducing the number of public items to less than 45. (undefined)
(ExcessivePublicCount)
[warning] 32-601: The class InputWeekTest has 50 non-getter- and setter-methods. Consider refactoring InputWeekTest to keep number of methods under 25. (undefined)
(TooManyMethods)
[warning] 32-601: The class InputWeekTest has 50 public methods. Consider refactoring InputWeekTest to keep number of public methods under 10. (undefined)
(TooManyPublicMethods)
[warning] 32-601: The class InputWeekTest has an overall complexity of 50 which is very high. The configured complexity threshold is 50. (undefined)
(ExcessiveClassComplexity)
[error] 32-601: The class InputWeekTest has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. (undefined)
(CouplingBetweenObjects)
[error] 279-279: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)
(StaticAccess)
[error] 287-287: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)
(StaticAccess)
[error] 552-552: Avoid using static access to class '\PHPForge\Support\LineEndingNormalizer' in method 'testRenderWithToString'. (undefined)
(StaticAccess)
[error] 552-552: Avoid using static access to class '\UIAwesome\Html\Form\InputWeek' in method 'testRenderWithToString'. (undefined)
(StaticAccess)
[error] 581-581: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)
(StaticAccess)
[error] 588-588: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)
(StaticAccess)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: phpunit / PHP 8.5-windows-2022
- GitHub Check: phpunit / PHP 8.1-ubuntu-latest
- GitHub Check: phpunit / PHP 8.2-windows-2022
- GitHub Check: phpunit / PHP 8.2-ubuntu-latest
- GitHub Check: phpunit / PHP 8.1-windows-2022
- GitHub Check: linter / Super Linter
- GitHub Check: mutation / PHP 8.5-ubuntu-latest
- GitHub Check: easy-coding-standard / PHP 8.5-ubuntu-latest
- GitHub Check: phpstan / PHP 8.5-ubuntu-latest
- GitHub Check: linter / Super Linter
🔇 Additional comments (2)
src/Form/InputWeek.php (1)
1-96: Clean implementation following established patterns.The class is well-structured, properly documented with usage examples and MDN link, and follows the same pattern as other input types in the library. The trait composition covers the relevant HTML attributes for
<input type="week">.CHANGELOG.md (1)
7-7: Verify the issue/PR number reference.The CHANGELOG references
#18, but this pull request is#19. Please confirm whether#18is the corresponding issue number or if this should be#19to match the PR.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@tests/Form/InputWeekTest.php`:
- Around line 277-288: Wrap the SimpleFactory::setDefaults usage in both test
methods so cleanup always runs: in testRenderWithGlobalDefaultsAreApplied and
testRenderWithUserOverridesGlobalDefaults, call
SimpleFactory::setDefaults(InputWeek::class, ['class'=>'default-class']) (or the
override values) inside the try block and move
SimpleFactory::setDefaults(InputWeek::class, []) into a finally block to
guarantee global defaults are cleared even if the assertion throws; locate these
calls by the method names testRenderWithGlobalDefaultsAreApplied,
testRenderWithUserOverridesGlobalDefaults and the SimpleFactory::setDefaults
references.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
tests/Form/InputWeekTest.php
🧰 Additional context used
🧬 Code graph analysis (1)
tests/Form/InputWeekTest.php (1)
src/Form/InputWeek.php (1)
InputWeek(51-96)
🪛 PHPMD (2.15.0)
tests/Form/InputWeekTest.php
[warning] 32-601: The class InputWeekTest has 50 public methods and attributes. Consider reducing the number of public items to less than 45. (undefined)
(ExcessivePublicCount)
[warning] 32-601: The class InputWeekTest has 50 non-getter- and setter-methods. Consider refactoring InputWeekTest to keep number of methods under 25. (undefined)
(TooManyMethods)
[warning] 32-601: The class InputWeekTest has 50 public methods. Consider refactoring InputWeekTest to keep number of public methods under 10. (undefined)
(TooManyPublicMethods)
[warning] 32-601: The class InputWeekTest has an overall complexity of 50 which is very high. The configured complexity threshold is 50. (undefined)
(ExcessiveClassComplexity)
[error] 32-601: The class InputWeekTest has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. (undefined)
(CouplingBetweenObjects)
[error] 279-279: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)
(StaticAccess)
[error] 287-287: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)
(StaticAccess)
[error] 552-552: Avoid using static access to class '\PHPForge\Support\LineEndingNormalizer' in method 'testRenderWithToString'. (undefined)
(StaticAccess)
[error] 552-552: Avoid using static access to class '\UIAwesome\Html\Form\InputWeek' in method 'testRenderWithToString'. (undefined)
(StaticAccess)
[error] 581-581: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)
(StaticAccess)
[error] 588-588: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)
(StaticAccess)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: easy-coding-standard / PHP 8.5-ubuntu-latest
- GitHub Check: phpstan / PHP 8.5-ubuntu-latest
- GitHub Check: phpunit / PHP 8.2-ubuntu-latest
- GitHub Check: phpunit / PHP 8.5-ubuntu-latest
- GitHub Check: phpunit / PHP 8.1-ubuntu-latest
- GitHub Check: phpunit / PHP 8.4-ubuntu-latest
- GitHub Check: linter / Super Linter
- GitHub Check: phpunit / PHP 8.3-ubuntu-latest
- GitHub Check: mutation / PHP 8.5-ubuntu-latest
- GitHub Check: phpunit / PHP 8.4-ubuntu-latest
- GitHub Check: linter / Super Linter
🔇 Additional comments (3)
tests/Form/InputWeekTest.php (3)
1-41: Test structure and basic attribute tests look good.The file is well-organized with clear, descriptive test names and assertion messages. The
testGetAttributeReturnsDefaultWhenMissingtest correctly verifies the fallback behavior.
43-513: Attribute and rendering tests are thorough and correct.The tests cover a comprehensive set of attributes (accesskey, aria, data, autocomplete, autofocus, class, dir, disabled, form, hidden, id, lang, list, max, min, name, readonly, required, role, step, style, title) with both string and enum variants where applicable. Assertion messages are consistently descriptive. The min/max combination test at lines 367–380 is a good addition for verifying multi-attribute rendering.
526-601: Provider, toString, translate, and value tests look correct.Theme provider, default provider,
__toString,translate(both string and enum), andvaluetests all follow the established patterns and verify expected output accurately.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Pull Request