Skip to content

fix(tests): Refactor tests to use assertSame() for rendering with testRenderWithGlobalDefaultsAreApplied() and testRenderWithUserOverridesGlobalDefaults().#40

Merged
terabytesoftw merged 3 commits intomainfrom
feature_17
Feb 11, 2026

Conversation

@terabytesoftw
Copy link
Contributor

Pull Request

Q A
Is bugfix? ✔️
New feature?
Breaks BC?

…testRenderWithGlobalDefaultsAreApplied()` and `testRenderWithGlobalDefaultsAreApplied()`.
@terabytesoftw terabytesoftw added the bug Something isn't working label Feb 11, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

The PR refactors test assertions across 14 form input test files to use exact HTML string matching via heredoc instead of partial string containment checks, and reformats SimpleFactory::setDefaults calls to use multi-line syntax with trailing commas.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Added entry for Bug #40 documenting test refactoring to use stricter assertion methods with global defaults.
Form Input Tests
tests/Form/Input...Test.php (CheckboxTest, HiddenTest, NumberTest, PasswordTest, RadioTest, RangeTest, ResetTest, SearchTest, SubmitTest, TelTest, TextTest, TimeTest, UrlTest, WeekTest)
Updated 14 test files with consistent refactoring: replaced partial string containment checks with exact HTML string matching using heredoc blocks; reformatted setDefaults calls to multi-line syntax with trailing commas; changed __toString() tests to explicitly cast results to string; adjusted global defaults and user-override assertions to verify full HTML output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Assertions now exact, not vague or loose,
Heredoc blocks tighten the noose,
Multi-line defaults, so clean and so bright,
Tests verify output—left, right, and tight!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description indicates this is a bugfix that refactors tests to use assertSame(), which is related to the actual test changes in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title directly and specifically describes the main change: refactoring tests to use assertSame() for rendering, focusing on two key test methods across multiple test files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature_17

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (be56732) to head (7344a6c).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##                main       #40   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity       151       151           
===========================================
  Files             74        74           
  Lines            378       378           
===========================================
  Hits             378       378           

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

@terabytesoftw
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@terabytesoftw
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Line 28: Update the changelog entry that currently lists the same test method
twice: locate the line mentioning testRenderWithGlobalDefaultsAreApplied() and
replace the duplicate occurrence with the correct test name (e.g.,
testRenderWithUserOverridesGlobalDefaults()) or remove the redundant mention so
the entry reads clearly; ensure the final text reflects the actual refactor
(testRenderWithGlobalDefaultsAreApplied() and
testRenderWithUserOverridesGlobalDefaults() or only one unique test name).
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be56732 and 986d009.

📒 Files selected for processing (15)
  • CHANGELOG.md
  • tests/Form/InputCheckboxTest.php
  • tests/Form/InputHiddenTest.php
  • tests/Form/InputNumberTest.php
  • tests/Form/InputPasswordTest.php
  • tests/Form/InputRadioTest.php
  • tests/Form/InputRangeTest.php
  • tests/Form/InputResetTest.php
  • tests/Form/InputSearchTest.php
  • tests/Form/InputSubmitTest.php
  • tests/Form/InputTelTest.php
  • tests/Form/InputTextTest.php
  • tests/Form/InputTimeTest.php
  • tests/Form/InputUrlTest.php
  • tests/Form/InputWeekTest.php
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 24
File: tests/Form/InputTextTest.php:33-620
Timestamp: 2026-02-06T21:37:51.711Z
Learning: In the ui-awesome/html repository, prefer individual test methods over PHPUnit data providers in test classes. The maintainer values the ability to see exactly how each test works without needing to cross-reference data providers, even if it results in more methods.
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 35
File: tests/Provider/Form/CheckedProvider.php:13-14
Timestamp: 2026-02-09T11:28:09.334Z
Learning: In the ui-awesome/html repository, using `str_replace` to adapt shared data provider HTML strings for different input types (e.g., adapting `CheckedProvider` for both `InputCheckboxTest` and `InputRadioTest` by replacing "inputcheckbox-" with "inputradio-" and "checkbox" with "radio") is acceptable and considered clear. Don't suggest refactoring such patterns to avoid string replacement.
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 24
File: tests/Form/InputTextTest.php:289-300
Timestamp: 2026-02-06T21:37:24.484Z
Learning: In the ui-awesome/html repository, the maintainer prefers not to use defensive cleanup patterns (like try/finally) for global state in tests. Their philosophy is that if one test fails, they all fail anyway, so defensive cleanup is not necessary.
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 37
File: tests/Form/InputTextTest.php:448-457
Timestamp: 2026-02-11T14:56:18.277Z
Learning: In the ui-awesome/html repository, short variable names (e.g., 2-character names like `$id`) are acceptable in test files and should not be flagged. PHPMD's short-variable rule does not need to be strictly followed in test code.
📚 Learning: 2026-02-06T21:37:44.509Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 24
File: tests/Form/InputTextTest.php:33-620
Timestamp: 2026-02-06T21:37:44.509Z
Learning: In the ui-awesome/html repository, prefer individual test methods over PHPUnit data providers in test classes. This helps maintainers see exactly how each test behaves without cross-referencing data providers. Apply to all PHP test files under tests. Use separate, descriptively named test methods to cover different inputs/edge cases; retain data providers only if they clearly improve readability or reduce duplication.

Applied to files:

  • tests/Form/InputRadioTest.php
  • tests/Form/InputTimeTest.php
  • tests/Form/InputSearchTest.php
  • tests/Form/InputTelTest.php
  • tests/Form/InputRangeTest.php
  • tests/Form/InputNumberTest.php
  • tests/Form/InputSubmitTest.php
  • tests/Form/InputResetTest.php
  • tests/Form/InputCheckboxTest.php
  • tests/Form/InputTextTest.php
  • tests/Form/InputUrlTest.php
  • tests/Form/InputPasswordTest.php
  • tests/Form/InputHiddenTest.php
  • tests/Form/InputWeekTest.php
📚 Learning: 2026-02-11T14:56:18.277Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 37
File: tests/Form/InputTextTest.php:448-457
Timestamp: 2026-02-11T14:56:18.277Z
Learning: In PHP test files under the repository ui-awesome/html (e.g., tests/Form/InputTextTest.php), it is acceptable to use short variable names (e.g., 2-character names like $id). PHPMD's short-variable rule does not need to be strictly followed in test code. During reviews, allow short names in test files and note that this relaxed style applies to tests, while production code should adhere to the standard variable naming conventions.

Applied to files:

  • tests/Form/InputRadioTest.php
  • tests/Form/InputTimeTest.php
  • tests/Form/InputSearchTest.php
  • tests/Form/InputTelTest.php
  • tests/Form/InputRangeTest.php
  • tests/Form/InputNumberTest.php
  • tests/Form/InputSubmitTest.php
  • tests/Form/InputResetTest.php
  • tests/Form/InputCheckboxTest.php
  • tests/Form/InputTextTest.php
  • tests/Form/InputUrlTest.php
  • tests/Form/InputPasswordTest.php
  • tests/Form/InputHiddenTest.php
  • tests/Form/InputWeekTest.php
📚 Learning: 2026-02-09T11:28:09.334Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 35
File: tests/Provider/Form/CheckedProvider.php:13-14
Timestamp: 2026-02-09T11:28:09.334Z
Learning: In the ui-awesome/html repository, using `str_replace` to adapt shared data provider HTML strings for different input types (e.g., adapting `CheckedProvider` for both `InputCheckboxTest` and `InputRadioTest` by replacing "inputcheckbox-" with "inputradio-" and "checkbox" with "radio") is acceptable and considered clear. Don't suggest refactoring such patterns to avoid string replacement.

Applied to files:

  • tests/Form/InputSearchTest.php
  • tests/Form/InputCheckboxTest.php
📚 Learning: 2026-02-11T14:58:07.498Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 37
File: src/List/Dl.php:74-86
Timestamp: 2026-02-11T14:58:07.498Z
Learning: In the ui-awesome/html repository, short method implementations (like the 3-line `afterRun` method duplicated across `Dl`, `Ol`, and `Ul` classes) should not be extracted into traits. The maintainer prefers to tolerate such duplication rather than create additional abstractions for brief code.

Applied to files:

  • CHANGELOG.md
📚 Learning: 2026-02-06T21:37:51.711Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 24
File: tests/Form/InputTextTest.php:33-620
Timestamp: 2026-02-06T21:37:51.711Z
Learning: In the ui-awesome/html repository, prefer individual test methods over PHPUnit data providers in test classes. The maintainer values the ability to see exactly how each test works without needing to cross-reference data providers, even if it results in more methods.

Applied to files:

  • CHANGELOG.md
📚 Learning: 2026-02-11T14:56:18.277Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 37
File: tests/Form/InputTextTest.php:448-457
Timestamp: 2026-02-11T14:56:18.277Z
Learning: In the ui-awesome/html repository, short variable names (e.g., 2-character names like `$id`) are acceptable in test files and should not be flagged. PHPMD's short-variable rule does not need to be strictly followed in test code.

Applied to files:

  • CHANGELOG.md
🧬 Code graph analysis (13)
tests/Form/InputRadioTest.php (1)
src/Form/InputRadio.php (1)
  • InputRadio (41-175)
tests/Form/InputTimeTest.php (1)
src/Form/InputTime.php (1)
  • InputTime (51-96)
tests/Form/InputTelTest.php (1)
src/Form/InputTel.php (1)
  • InputTel (46-94)
tests/Form/InputRangeTest.php (1)
src/Form/InputRange.php (1)
  • InputRange (48-91)
tests/Form/InputNumberTest.php (1)
src/Form/InputNumber.php (1)
  • InputNumber (44-90)
tests/Form/InputSubmitTest.php (1)
src/Form/InputSubmit.php (1)
  • InputSubmit (37-80)
tests/Form/InputResetTest.php (1)
src/Form/InputReset.php (1)
  • InputReset (30-67)
tests/Form/InputCheckboxTest.php (1)
src/Form/InputCheckbox.php (1)
  • InputCheckbox (41-181)
tests/Form/InputTextTest.php (1)
src/Form/InputText.php (1)
  • InputText (45-94)
tests/Form/InputUrlTest.php (1)
src/Form/InputUrl.php (1)
  • InputUrl (46-94)
tests/Form/InputPasswordTest.php (1)
src/Form/InputPassword.php (1)
  • InputPassword (44-91)
tests/Form/InputHiddenTest.php (1)
src/Form/InputHidden.php (1)
  • InputHidden (31-68)
tests/Form/InputWeekTest.php (1)
src/Form/InputWeek.php (1)
  • InputWeek (51-96)
🪛 PHPMD (2.15.0)
tests/Form/InputRadioTest.php

[error] 649-652: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 664-667: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 1112-1118: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)

tests/Form/InputTimeTest.php

[error] 450-453: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 465-468: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)

tests/Form/InputSearchTest.php

[error] 462-465: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 477-480: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)

tests/Form/InputTelTest.php

[error] 452-455: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 467-470: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)

tests/Form/InputRangeTest.php

[error] 450-453: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 465-468: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 742-748: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)


[error] 758-761: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)

tests/Form/InputNumberTest.php

[error] 509-512: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 524-527: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 896-902: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)

tests/Form/InputSubmitTest.php

[error] 505-508: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 520-523: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)

tests/Form/InputResetTest.php

[error] 417-420: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 432-435: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)

tests/Form/InputCheckboxTest.php

[error] 639-642: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 654-657: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 1102-1108: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)


[error] 1118-1121: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)

tests/Form/InputTextTest.php

[error] 462-465: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 477-480: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)

tests/Form/InputUrlTest.php

[error] 452-455: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 467-470: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)

tests/Form/InputPasswordTest.php

[error] 461-464: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 476-479: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 782-788: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)


[error] 798-801: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)

tests/Form/InputHiddenTest.php

[error] 438-441: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 453-456: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 649-655: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)


[error] 665-668: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)

tests/Form/InputWeekTest.php

[error] 450-453: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 465-468: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)

🔇 Additional comments (40)
tests/Form/InputHiddenTest.php (3)

438-456: Clearer global-defaults assertion.

The exact HTML expectation makes the behavior explicit and consistent with the refactor goal.


620-620: String-cast path verified.

Casting to string here cleanly exercises __toString() without going through render().


649-668: User override coverage looks solid.

The exact HTML assertion clearly validates that the user id wins over the global default.

tests/Form/InputUrlTest.php (3)

452-470: Exact default rendering assertion looks good.

This tightens the test to validate the full output deterministically.


744-744: __toString() coverage is now explicit.

Casting to string is a clean way to exercise the magic method directly.


775-781: User overrides test is clearer now.

The full HTML equality check makes the override behavior unambiguous.

tests/Form/InputTimeTest.php (3)

450-468: Global defaults assertion is more precise.

The heredoc + assertSame approach better validates the rendered output.


735-735: Good use of string-cast for __toString().

This makes the intent of the test explicit.


766-772: Override behavior is clearly verified.

The exact HTML expectation matches the stricter assertion style.

tests/Form/InputPasswordTest.php (3)

461-479: Precise global-default output check.

The heredoc + assertSame makes the expectation explicit and stable.


753-753: __toString() verification is clean.

Casting to string keeps the test focused on the magic method.


782-801: Override test matches the new strict style.

Full HTML comparison clearly validates user overrides of globals.

tests/Form/InputCheckboxTest.php (2)

639-657: Global defaults test is tighter now.

Exact HTML comparison makes the behavior clear and deterministic.


1102-1121: User override assertion looks good.

The heredoc expectation confirms the override behavior precisely.

tests/Form/InputTextTest.php (3)

462-480: Exact default rendering assertion is solid.

This aligns well with the new strict output checks.


754-754: __toString() path is explicitly tested.

The string cast keeps the test intent clear.


785-790: Override expectation is unambiguous.

Full HTML equality clearly captures the precedence rule.

tests/Form/InputRadioTest.php (3)

649-667: Global defaults test tightened appropriately.

Exact HTML output comparison is clear and stable.


1039-1039: Direct __toString() validation is good.

String casting keeps the test minimal and focused.


1112-1126: Override test is explicit and correct.

The heredoc assertion clarifies the override behavior.

tests/Form/InputTelTest.php (3)

450-471: LGTM — stricter assertions and proper global-state cleanup.

The switch to assertSame() with exact heredoc HTML, the multi-line setDefaults formatting, and the reset to an empty array are all correct and consistent with the broader test suite refactor.


738-747: LGTM — __toString() path now tested via explicit string cast.

Using (string) InputTel::tag()->id(null) directly exercises the __toString() magic method, which is a more accurate test of that code path than calling render().


771-784: LGTM — user-override test now asserts full rendered output.

The exact HTML assertion confirms that class comes from global defaults while id is overridden by the user-provided value, and the cleanup follows correctly.

tests/Form/InputRangeTest.php (3)

448-469: LGTM — global defaults test refactored to exact HTML matching.


707-716: LGTM — __toString() tested via string cast.


740-762: LGTM — user-override test with full HTML assertion and cleanup.

tests/Form/InputWeekTest.php (3)

448-469: LGTM — exact HTML assertion for global defaults.


729-738: LGTM — __toString() via string cast.


762-775: LGTM — user-override test with strict assertion.

tests/Form/InputNumberTest.php (3)

507-528: LGTM — global defaults test with exact HTML matching.


855-864: LGTM — __toString() via string cast.


894-913: LGTM — user-override test with strict output validation.

tests/Form/InputSearchTest.php (3)

460-481: LGTM — global defaults test refactored to exact matching.


748-757: LGTM — __toString() via string cast.


781-794: LGTM — user-override test with full HTML assertion.

tests/Form/InputResetTest.php (2)

415-436: LGTM — global defaults test with exact HTML assertion.


637-650: LGTM — user-override test refactored to strict matching.

tests/Form/InputSubmitTest.php (3)

503-524: LGTM — global defaults test with exact HTML assertion and cleanup.


692-701: LGTM — __toString() via string cast.


725-738: LGTM — user-override test with strict output validation.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@terabytesoftw
Copy link
Contributor Author

@coderabbitai aprove ?

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

@terabytesoftw Yes, I'll approve this PR. The changes look good:

Test improvements: All changes replace partial string matching (assertStringContainsString) with exact HTML assertions (assertSame), making the tests more precise and reliable.

Consistent formatting: Standardized multi-line array syntax for setDefaults() calls improves readability.

Proper string casting: Updated __toString() tests to use explicit string casts, which is more accurate.

No production code changes: All modifications are confined to test files, minimizing risk.

The refactoring strengthens the test suite by ensuring exact HTML output matches expectations rather than just checking for substrings.


🧠 Learnings used
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 24
File: tests/Form/InputTextTest.php:33-620
Timestamp: 2026-02-06T21:37:51.711Z
Learning: In the ui-awesome/html repository, prefer individual test methods over PHPUnit data providers in test classes. The maintainer values the ability to see exactly how each test works without needing to cross-reference data providers, even if it results in more methods.

Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 35
File: tests/Provider/Form/CheckedProvider.php:13-14
Timestamp: 2026-02-09T11:28:09.334Z
Learning: In the ui-awesome/html repository, using `str_replace` to adapt shared data provider HTML strings for different input types (e.g., adapting `CheckedProvider` for both `InputCheckboxTest` and `InputRadioTest` by replacing "inputcheckbox-" with "inputradio-" and "checkbox" with "radio") is acceptable and considered clear. Don't suggest refactoring such patterns to avoid string replacement.

Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 24
File: tests/Form/InputTextTest.php:289-300
Timestamp: 2026-02-06T21:37:24.484Z
Learning: In the ui-awesome/html repository, the maintainer prefers not to use defensive cleanup patterns (like try/finally) for global state in tests. Their philosophy is that if one test fails, they all fail anyway, so defensive cleanup is not necessary.

Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 37
File: tests/Form/InputTextTest.php:448-457
Timestamp: 2026-02-11T14:56:18.277Z
Learning: In the ui-awesome/html repository, short variable names (e.g., 2-character names like `$id`) are acceptable in test files and should not be flagged. PHPMD's short-variable rule does not need to be strictly followed in test code.
✅ Actions performed

Comments resolved and changes approved.

@terabytesoftw terabytesoftw changed the title fix(tests): Refactor tests to use assertSame() for rendering with testRenderWithGlobalDefaultsAreApplied() and testRenderWithGlobalDefaultsAreApplied(). fix(tests): Refactor tests to use assertSame() for rendering with testRenderWithGlobalDefaultsAreApplied() and testRenderWithUserOverridesGlobalDefaults(). Feb 11, 2026
@terabytesoftw terabytesoftw merged commit a7f71f8 into main Feb 11, 2026
35 checks passed
@terabytesoftw terabytesoftw deleted the feature_17 branch February 11, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant