Skip to content

fix(tests): Update exception test method names for consistency and clarity,#55

Merged
terabytesoftw merged 2 commits intomainfrom
fix_mini_13
Feb 21, 2026
Merged

fix(tests): Update exception test method names for consistency and clarity,#55
terabytesoftw merged 2 commits intomainfrom
fix_mini_13

Conversation

@terabytesoftw
Copy link
Contributor

Pull Request

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

@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

Warning

Rate limit exceeded

@terabytesoftw has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 13 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a7ea44f and 8af38a6.

📒 Files selected for processing (1)
  • tests/Embedded/ImgTest.php
📝 Walkthrough

Walkthrough

This PR renames test methods from a "ForSetting" to "WhenSetting" naming pattern across multiple test files for consistency, updates PHPDoc descriptions in source enums to clarify "values" terminology, and refactors test assertions to use enum-backed values instead of hard-coded strings.

Changes

Cohort / File(s) Summary
Documentation Updates
CHANGELOG.md, src/Form/Values/Capture.php, src/Form/Values/Colorspace.php, src/Metadata/Values/ShadowRootMode.php
Added changelog entry for bug fix; updated PHPDoc descriptions across enum classes to clarify "values" terminology and remove outdated usage examples.
Test Method Refactoring
tests/Embedded/ImgTest.php, tests/Form/InputColorTest.php, tests/Form/TextAreaTest.php, tests/Metadata/BaseTest.php, tests/Metadata/LinkTest.php, tests/Metadata/MetaTest.php, tests/Metadata/ScriptTest.php, tests/Metadata/StyleTest.php, tests/Metadata/TemplateTest.php
Renamed test methods from "ForSetting" to "WhenSetting" pattern; updated test assertions to use enum-backed attribute values (e.g., Attribute::BLOCKING->value) instead of hard-coded strings; added necessary enum imports for improved test maintainability.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

bug

Poem

🐰 Hops and tweaks, names all refined,
From "ForSetting" to "WhenSetting" aligned,
Enums now speak where strings once lay,
Bug #54 hops away! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: renaming test methods from 'ForSetting' to 'WhenSetting' patterns for consistency and clarity across multiple test files.
Description check ✅ Passed The description clearly identifies this as a bugfix focused on updating exception test method names for consistency and clarity, which directly relates to the changeset.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_mini_13

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 21, 2026

Codecov Report

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

Additional details and impacted files
@@             Coverage Diff             @@
##                main       #55   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity       171       171           
===========================================
  Files             88        88           
  Lines            410       410           
===========================================
  Hits             410       410           

☔ 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 21, 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.

@coderabbitai coderabbitai bot added the bug Something isn't working label Feb 21, 2026
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tests/Embedded/ImgTest.php (1)

914-926: ⚠️ Potential issue | 🟡 Minor

Inconsistent method name: WhenInvalid vs WhenSetting.

All other new exception tests in this PR (and in this file) follow the testThrowInvalidArgumentExceptionWhenSetting* pattern, but this method uses WhenInvalid. Consider renaming to testThrowInvalidArgumentExceptionWhenSettingCrossorigin for consistency with the PR's stated goal.

✏️ Proposed rename
-    public function testThrowInvalidArgumentExceptionWhenInvalidCrossorigin(): void
+    public function testThrowInvalidArgumentExceptionWhenSettingCrossorigin(): void
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/Embedded/ImgTest.php` around lines 914 - 926, Rename the test method
testThrowInvalidArgumentExceptionWhenInvalidCrossorigin to match the project's
naming convention (e.g.,
testThrowInvalidArgumentExceptionWhenSettingCrossorigin); update the method
declaration only, leaving the assertions and call to
Img::tag()->crossorigin('invalid-value') intact so the test behavior is
unchanged but the name follows the testThrowInvalidArgumentExceptionWhenSetting*
pattern used elsewhere.
tests/Metadata/MetaTest.php (1)

645-656: ⚠️ Potential issue | 🔴 Critical

The test will fail with a fatal error because the Attribute enum does not exist in the codebase.

The test imports Attribute from UIAwesome\Html\Attribute\Values, and line 651 references Attribute::HTTP_EQUIV->value. However, exhaustive search of the entire repository confirms that:

  • No Attribute enum exists anywhere
  • No HttpEquiv enum exists anywhere
  • The src/Attribute/Values/ directory does not exist
  • The import path is invalid

When the test runs, it will throw a fatal error (Class "UIAwesome\Html\Attribute\Values\Attribute" not found) rather than reaching the InvalidArgumentException assertion. Both the Attribute enum and the HttpEquiv enum must be created before this test can execute.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/Metadata/MetaTest.php` around lines 645 - 656, Create two enums under
the namespace UIAwesome\Html\Attribute\Values named Attribute and HttpEquiv so
the test can reference Attribute::HTTP_EQUIV->value and HttpEquiv::cases();
ensure Attribute defines a HTTP_EQUIV case (with the expected string value used
by Meta::tag()->httpEquiv) and HttpEquiv exposes the set of allowed http-equiv
values used by Enum::normalizeArray(HttpEquiv::cases()); implement them as PHP
backed-enums (so ->value works) and place them at the import path referenced by
the test so the class autoloader can find them.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf7b934 and a7ea44f.

📒 Files selected for processing (13)
  • CHANGELOG.md
  • src/Form/Values/Capture.php
  • src/Form/Values/Colorspace.php
  • src/Metadata/Values/ShadowRootMode.php
  • tests/Embedded/ImgTest.php
  • tests/Form/InputColorTest.php
  • tests/Form/TextAreaTest.php
  • tests/Metadata/BaseTest.php
  • tests/Metadata/LinkTest.php
  • tests/Metadata/MetaTest.php
  • tests/Metadata/ScriptTest.php
  • tests/Metadata/StyleTest.php
  • tests/Metadata/TemplateTest.php
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 51
File: tests/List/UlTest.php:282-283
Timestamp: 2026-02-21T01:17:50.737Z
Learning: In the ui-awesome/html repository, test assertion messages for `testRenderWith*UsingEnum` methods should remain identical to their non-enum counterparts (without "using enum" suffix). The maintainer prefers this because the underlying method behavior doesn't differentiate between enum and string inputs, so the failure messages should reflect that uniformity.
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 37
File: tests/Form/InputTextTest.php:448-457
Timestamp: 2026-02-11T14:56:26.855Z
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.
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.
📚 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/Metadata/TemplateTest.php
  • tests/Form/TextAreaTest.php
  • tests/Metadata/BaseTest.php
  • tests/Metadata/StyleTest.php
  • tests/Embedded/ImgTest.php
  • tests/Metadata/MetaTest.php
  • tests/Metadata/LinkTest.php
  • tests/Form/InputColorTest.php
  • tests/Metadata/ScriptTest.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/Metadata/TemplateTest.php
  • tests/Form/TextAreaTest.php
  • tests/Metadata/BaseTest.php
  • tests/Metadata/StyleTest.php
  • tests/Embedded/ImgTest.php
  • tests/Metadata/MetaTest.php
  • tests/Metadata/LinkTest.php
  • tests/Form/InputColorTest.php
  • tests/Metadata/ScriptTest.php
📚 Learning: 2026-02-21T01:17:40.877Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 51
File: tests/List/UlTest.php:282-283
Timestamp: 2026-02-21T01:17:40.877Z
Learning: In the ui-awesome/html repository, for PHP tests, ensure that assertion messages in tests/List/UlTest.php for methods named testRenderWith*UsingEnum remain identical to the corresponding non-enum tests (i.e., do not append 'using enum' to the failure message). The reason: the underlying render method treats enum and string inputs the same, so failure output should be uniform. Apply this pattern to all similar test cases under tests/ to maintain consistent failure messages across enum vs non-enum variants.

Applied to files:

  • tests/Metadata/TemplateTest.php
  • tests/Form/TextAreaTest.php
  • tests/Metadata/BaseTest.php
  • tests/Metadata/StyleTest.php
  • tests/Embedded/ImgTest.php
  • tests/Metadata/MetaTest.php
  • tests/Metadata/LinkTest.php
  • tests/Form/InputColorTest.php
  • tests/Metadata/ScriptTest.php
📚 Learning: 2026-02-07T18:51:41.006Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 31
File: src/Form/Mixin/HasLabel.php:195-195
Timestamp: 2026-02-07T18:51:41.006Z
Learning: In the ui-awesome/html repository, explicit boolean comparisons (e.g., `isset($var) === false`) are required instead of negation operators (e.g., `!isset($var)`) due to PHPStan strict rules configuration at the highest level.

Applied to files:

  • tests/Metadata/BaseTest.php
  • tests/Metadata/StyleTest.php
  • tests/Embedded/ImgTest.php
  • tests/Metadata/MetaTest.php
  • tests/Metadata/ScriptTest.php
🧬 Code graph analysis (1)
tests/Metadata/StyleTest.php (2)
tests/Metadata/LinkTest.php (1)
  • testThrowInvalidArgumentExceptionWhenSettingBlocking (849-861)
tests/Metadata/ScriptTest.php (1)
  • testThrowInvalidArgumentExceptionWhenSettingBlocking (1038-1050)
🪛 PHPMD (2.15.0)
tests/Embedded/ImgTest.php

[error] 921-921: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenInvalidCrossorigin'. (undefined)

(StaticAccess)


[error] 921-921: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Crossorigin' in method 'testThrowInvalidArgumentExceptionWhenInvalidCrossorigin'. (undefined)

(StaticAccess)


[error] 935-935: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingDecoding'. (undefined)

(StaticAccess)


[error] 935-935: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Decoding' in method 'testThrowInvalidArgumentExceptionWhenSettingDecoding'. (undefined)

(StaticAccess)


[error] 949-949: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingFetchpriority'. (undefined)

(StaticAccess)


[error] 949-949: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Fetchpriority' in method 'testThrowInvalidArgumentExceptionWhenSettingFetchpriority'. (undefined)

(StaticAccess)


[error] 963-963: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingLoading'. (undefined)

(StaticAccess)


[error] 963-963: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Loading' in method 'testThrowInvalidArgumentExceptionWhenSettingLoading'. (undefined)

(StaticAccess)


[error] 977-977: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingReferrerpolicy'. (undefined)

(StaticAccess)


[error] 977-977: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Referrerpolicy' in method 'testThrowInvalidArgumentExceptionWhenSettingReferrerpolicy'. (undefined)

(StaticAccess)

tests/Metadata/LinkTest.php

[error] 856-856: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingBlocking'. (undefined)

(StaticAccess)


[error] 856-856: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Blocking' in method 'testThrowInvalidArgumentExceptionWhenSettingBlocking'. (undefined)

(StaticAccess)


[error] 870-870: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingCrossorigin'. (undefined)

(StaticAccess)


[error] 870-870: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Crossorigin' in method 'testThrowInvalidArgumentExceptionWhenSettingCrossorigin'. (undefined)

(StaticAccess)


[error] 884-884: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingFetchpriority'. (undefined)

(StaticAccess)


[error] 884-884: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Fetchpriority' in method 'testThrowInvalidArgumentExceptionWhenSettingFetchpriority'. (undefined)

(StaticAccess)

tests/Metadata/ScriptTest.php

[error] 1045-1045: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingBlocking'. (undefined)

(StaticAccess)


[error] 1045-1045: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Blocking' in method 'testThrowInvalidArgumentExceptionWhenSettingBlocking'. (undefined)

(StaticAccess)


[error] 1059-1059: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingCrossorigin'. (undefined)

(StaticAccess)


[error] 1059-1059: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Crossorigin' in method 'testThrowInvalidArgumentExceptionWhenSettingCrossorigin'. (undefined)

(StaticAccess)


[error] 1073-1073: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingFetchpriority'. (undefined)

(StaticAccess)


[error] 1073-1073: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Fetchpriority' in method 'testThrowInvalidArgumentExceptionWhenSettingFetchpriority'. (undefined)

(StaticAccess)

🔇 Additional comments (11)
src/Form/Values/Colorspace.php (1)

8-8: LGTM — consistent docblock wording cleanup.

src/Form/Values/Capture.php (1)

8-8: LGTM — consistent docblock wording cleanup.

src/Metadata/Values/ShadowRootMode.php (1)

8-8: LGTM — consistent with the docblock wording updates across sibling value enums.

CHANGELOG.md (1)

42-42: LGTM — entry is correctly placed and describes the change accurately.

tests/Metadata/StyleTest.php (1)

878-890: LGTM — method rename and Attribute::BLOCKING->value usage are consistent with LinkTest and ScriptTest.

tests/Metadata/BaseTest.php (1)

594-606: LGTM — method rename and Attribute::TARGET->value usage are consistent with the pattern adopted in StyleTest and the wider metadata suite.

tests/Metadata/TemplateTest.php (1)

882-894: No action needed — literal 'shadowrootmode' is correct.

The literal string 'shadowrootmode' is intentional. Unlike StyleTest and BaseTest, TemplateTest does not import the general Attribute enum. Instead, it imports the template-specific ShadowRootMode enum, indicating that shadowrootmode is not a case in the general Attribute enum. The bare string is the appropriate choice here.

tests/Form/InputColorTest.php (1)

986-998: Verify whether Attribute::COLORSPACE exists in the codebase.

The review identifies an inconsistency pattern: StyleTest and BaseTest use Attribute::BLOCKING->value and Attribute::TARGET->value in exception messages, while InputColorTest uses the literal string 'colorspace'. The concern is whether an Attribute::COLORSPACE case exists that should be used instead.

Since colorspace is an <input type="color">-specific attribute (similar to how domain-specific enums like Colorspace.php exist in src/Form/Values/), the literal string usage may be intentional and correct. However, this cannot be confirmed without locating the Attribute enum definition to verify the presence or absence of a COLORSPACE case.

tests/Form/TextAreaTest.php (1)

1009-1049: LGTM — renames are clean and consistent.

All three testThrowInvalidArgumentExceptionWhenSetting* renames align with the PR's naming convention and no logic is altered.

tests/Metadata/LinkTest.php (1)

849-903: LGTM — renames and enum-backed values are applied consistently.

All four exception tests follow the WhenSetting pattern and correctly replace hard-coded attribute-name strings with enum-backed values. Note that Attribute::BLOCKING is not visible in the partial snippet; its existence is covered by the verification script raised in MetaTest.php.

tests/Metadata/ScriptTest.php (1)

1038-1092: LGTM — renames and enum-backed values are consistent with the rest of the suite.

All four methods follow the WhenSetting convention and replace hard-coded strings with Attribute::*->value references, matching the pattern in LinkTest.php.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@tests/Embedded/ImgTest.php`:
- Around line 914-926: Rename the test method
testThrowInvalidArgumentExceptionWhenInvalidCrossorigin to match the project's
naming convention (e.g.,
testThrowInvalidArgumentExceptionWhenSettingCrossorigin); update the method
declaration only, leaving the assertions and call to
Img::tag()->crossorigin('invalid-value') intact so the test behavior is
unchanged but the name follows the testThrowInvalidArgumentExceptionWhenSetting*
pattern used elsewhere.

In `@tests/Metadata/MetaTest.php`:
- Around line 645-656: Create two enums under the namespace
UIAwesome\Html\Attribute\Values named Attribute and HttpEquiv so the test can
reference Attribute::HTTP_EQUIV->value and HttpEquiv::cases(); ensure Attribute
defines a HTTP_EQUIV case (with the expected string value used by
Meta::tag()->httpEquiv) and HttpEquiv exposes the set of allowed http-equiv
values used by Enum::normalizeArray(HttpEquiv::cases()); implement them as PHP
backed-enums (so ->value works) and place them at the import path referenced by
the test so the class autoloader can find them.

@terabytesoftw terabytesoftw merged commit 9df944f into main Feb 21, 2026
49 checks passed
@terabytesoftw terabytesoftw deleted the fix_mini_13 branch February 21, 2026 18:52
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