Skip to content

Issue/481 enum exception coverage#484

Merged
armanist merged 29 commits into
quantum-php:masterfrom
armanist:issue/481-enum-exception-coverage
Apr 29, 2026
Merged

Issue/481 enum exception coverage#484
armanist merged 29 commits into
quantum-php:masterfrom
armanist:issue/481-enum-exception-coverage

Conversation

@armanist

@armanist armanist commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator

Closes #481

Summary by CodeRabbit

  • Tests

    • Added comprehensive unit test coverage for exception classes across modules (Auth, Config, Database, Http, Router, View, and others) to verify exception messages and error codes.
  • Chores

    • Internal refactoring of constant container classes to prevent unintended instantiation while maintaining existing functionality.
    • Updated code coverage configuration for exception classes.

armanist added 27 commits April 29, 2026 18:02
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

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

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7aa3b0db-2c54-4639-96ff-e3ab0880382d

📥 Commits

Reviewing files that changed from the base of the PR and between 8bd7838 and 6efc846.

📒 Files selected for processing (23)
  • src/Captcha/Exceptions/CaptchaException.php
  • tests/Unit/App/Exceptions/AppExceptionTest.php
  • tests/Unit/App/Exceptions/BaseExceptionTest.php
  • tests/Unit/Csrf/Exceptions/CsrfExceptionTest.php
  • tests/Unit/Database/Exceptions/DatabaseExceptionTest.php
  • tests/Unit/Di/Exceptions/DiExceptionTest.php
  • tests/Unit/Encryption/Exceptions/CryptorExceptionTest.php
  • tests/Unit/Environment/Exceptions/EnvExceptionTest.php
  • tests/Unit/Hook/Exceptions/HookExceptionTest.php
  • tests/Unit/HttpClient/Exceptions/HttpClientExceptionTest.php
  • tests/Unit/Jwt/Exceptions/JwtExceptionTest.php
  • tests/Unit/Lang/Exceptions/LangExceptionTest.php
  • tests/Unit/Logger/Exceptions/LoggerExceptionTest.php
  • tests/Unit/Middleware/Exceptions/MiddlewareExceptionTest.php
  • tests/Unit/Migration/Exceptions/MigrationExceptionTest.php
  • tests/Unit/Model/Exceptions/ModelExceptionTest.php
  • tests/Unit/Module/Exceptions/ModuleExceptionTest.php
  • tests/Unit/Paginator/Exceptions/PaginatorExceptionTest.php
  • tests/Unit/Router/Exceptions/RouteExceptionTest.php
  • tests/Unit/Session/Exceptions/SessionExceptionTest.php
  • tests/Unit/Storage/Exceptions/FileSystemExceptionTest.php
  • tests/Unit/Storage/Exceptions/FileUploadExceptionTest.php
  • tests/Unit/View/Exceptions/ViewExceptionTest.php
📝 Walkthrough

Walkthrough

This pull request normalizes enum and exception coverage conventions across the codebase by: (1) making enum-like constant-holder classes final with private __construct() and @codeCoverageIgnore, (2) marking exception pass-through wrappers with @codeCoverageIgnore, and (3) adding focused unit tests for exception factory methods to validate message and error code behavior.

Changes

Cohort / File(s) Summary
Enum constant-holder class normalization
src/Auth/Enums/AuthKeys.php, src/Cron/Enums/ExceptionMessages.php, src/Database/Enums/Key.php, src/Database/Enums/Relation.php, src/Database/Enums/Type.php, src/Environment/Enums/Env.php, src/Http/Enums/ContentType.php, src/Http/Enums/StatusCode.php, src/Paginator/Enums/Pagination.php
Made classes final, added private __construct() to prevent instantiation, and added @codeCoverageIgnore docblock annotation to exclude pure constant holders from coverage reporting.
Exception pass-through wrapper coverage exclusion
src/Cache/Exceptions/CacheException.php, src/Captcha/Exceptions/CaptchaException.php, src/Http/Exceptions/HttpException.php, src/Loader/Exceptions/LoaderException.php, src/Mailer/Exceptions/MailerException.php, src/Renderer/Exceptions/RendererException.php, src/ResourceCache/Exceptions/ResourceCacheException.php, src/Service/Exceptions/ServiceException.php
Added @codeCoverageIgnore annotation to exclude trivial exception wrapper classes from code coverage reporting.
Exception factory method unit tests
tests/Unit/App/Exceptions/AppExceptionTest.php, tests/Unit/App/Exceptions/BaseExceptionTest.php, tests/Unit/Archive/Exceptions/ArchiveExceptionTest.php, tests/Unit/Asset/Exceptions/AssetExceptionTest.php, tests/Unit/Auth/Exceptions/AuthExceptionTest.php, tests/Unit/Config/Exceptions/ConfigExceptionTest.php, tests/Unit/Csrf/Exceptions/CsrfExceptionTest.php, tests/Unit/Database/Exceptions/DatabaseExceptionTest.php, tests/Unit/Di/Exceptions/DiExceptionTest.php, tests/Unit/Encryption/Exceptions/CryptorExceptionTest.php, tests/Unit/Environment/Exceptions/EnvExceptionTest.php, tests/Unit/Hasher/Exceptions/HasherExceptionTest.php, tests/Unit/Hook/Exceptions/HookExceptionTest.php, tests/Unit/HttpClient/Exceptions/HttpClientExceptionTest.php, tests/Unit/Jwt/Exceptions/JwtExceptionTest.php, tests/Unit/Lang/Exceptions/LangExceptionTest.php, tests/Unit/Logger/Exceptions/LoggerExceptionTest.php, tests/Unit/Middleware/Exceptions/MiddlewareExceptionTest.php, tests/Unit/Migration/Exceptions/MigrationExceptionTest.php, tests/Unit/Model/Exceptions/ModelExceptionTest.php, tests/Unit/Module/Exceptions/ModuleExceptionTest.php, tests/Unit/Paginator/Exceptions/PaginatorExceptionTest.php, tests/Unit/Router/Exceptions/RouteExceptionTest.php, tests/Unit/Session/Exceptions/SessionExceptionTest.php, tests/Unit/Storage/Exceptions/FileSystemExceptionTest.php, tests/Unit/Storage/Exceptions/FileUploadExceptionTest.php, tests/Unit/View/Exceptions/ViewExceptionTest.php
Added focused unit tests for exception factory methods, each verifying that static factory methods return correct exception instances with expected message strings and PHP error codes (E_ERROR, E_WARNING, E_NOTICE).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

enhancement

Suggested reviewers

  • andrey-smaelov
  • charoyan88
  • grigoryanmartin20
  • live-soft
  • Arno2005

Poem

🐰 Enum and exception rules so bright,
Making coverage patterns tight!
Final classes, constructors sealed,
Test factories now revealed,
Code consistency takes flight!

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Issue/481 enum exception coverage' directly references the issue number and accurately describes the main changes: standardizing enum-like classes and exception testing coverage across the codebase.
Linked Issues check ✅ Passed The PR fully implements the acceptance criteria from issue #481: enum-like constants are made final with private constructors and @codeCoverageIgnore, exception factory methods are tested with validation of message/code/previous, and focused unit tests verify behavior rather than just constants.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #481 objectives: normalizing enum/exception coverage conventions. No unrelated refactoring, feature additions, or ancillary modifications are present in 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

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
Review rate limit: 0/1 reviews remaining, refill in 33 minutes and 4 seconds.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 18

Caution

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

⚠️ Outside diff range comments (7)
tests/Unit/Session/Exceptions/SessionExceptionTest.php (1)

1-29: ⚠️ Potential issue | 🟡 Minor

Re-run PHP CS Fixer before merge.

The test coverage looks correct, but CI is still failing this file on PHP CS Fixer.

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

In `@tests/Unit/Session/Exceptions/SessionExceptionTest.php` around lines 1 - 29,
Run PHP CS Fixer on the tests file and fix formatting issues in the
SessionExceptionTest class (SessionExceptionTest, testSessionNotStarted,
testSessionNotDestroyed) so it complies with project coding standards; re-run
the fixer until no changes are suggested and commit the formatted file.
tests/Unit/Csrf/Exceptions/CsrfExceptionTest.php (1)

1-29: ⚠️ Potential issue | 🟡 Minor

Re-run PHP CS Fixer before merge.

The factory coverage is correct, but this file is still not CS-compliant.

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

In `@tests/Unit/Csrf/Exceptions/CsrfExceptionTest.php` around lines 1 - 29, This
test file isn’t PHP-CS-Fixer compliant; run the project's PHP CS Fixer (or the
configured linter) and apply the automatic fixes to CsrfExceptionTest (ensure
file header spacing, indentation, blank lines between methods, and PSR-12
conforming braces/whitespace in the class and methods testTokenNotFound and
testTokenNotMatched are corrected) so the file matches the repo coding standards
before merging.
tests/Unit/Storage/Exceptions/FileSystemExceptionTest.php (1)

1-32: ⚠️ Potential issue | 🟡 Minor

Re-run PHP CS Fixer before merge.

The assertions look fine, but CI is still reporting this file as not CS-compliant.

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

In `@tests/Unit/Storage/Exceptions/FileSystemExceptionTest.php` around lines 1 -
32, Run PHP CS Fixer to make this test file comply with project coding
standards; specifically reformat tests in the FileSystemExceptionTest class
(methods testDirectoryNotExists, testDirectoryNotWritable,
testFileAlreadyExists) by running the project's php-cs-fixer configuration
(e.g., php-cs-fixer fix) and commit the resulting whitespace/formatting changes
so CI passes.
tests/Unit/Environment/Exceptions/EnvExceptionTest.php (1)

1-29: ⚠️ Potential issue | 🟡 Minor

Re-run PHP CS Fixer before merge.

The assertions align with the exception factories, but this file is still not CS-compliant.

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

In `@tests/Unit/Environment/Exceptions/EnvExceptionTest.php` around lines 1 - 29,
This test file (EnvExceptionTest class, methods testEnvironmentImmutable and
testEnvironmentNotLoaded) is not PHP CS Fixer compliant; re-run php-cs-fixer (or
the project's fixer command) on this file to fix
formatting/spacing/namespace/import order and ensure it follows PSR-12 so the
file passes CI linting before merging.
tests/Unit/Di/Exceptions/DiExceptionTest.php (1)

1-53: ⚠️ Potential issue | 🟡 Minor

Re-run PHP CS Fixer before merge.

The tests cover the factory behavior well, but CI is still reporting this file as not CS-compliant.

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

In `@tests/Unit/Di/Exceptions/DiExceptionTest.php` around lines 1 - 53, Re-run PHP
CS Fixer (using the project config) and apply fixes to this test file so it
meets coding standards; run the fixer (e.g. php-cs-fixer fix .
--config=.php_cs.dist) or your repo's configured command, then re-check and
commit the updated DiExceptionTest.php changes (class DiExceptionTest and its
test methods testDependencyFactories, testAbstractAndCircularFactories,
testInvalidCallableFactory) before merging so CI no longer flags CS violations.
tests/Unit/Storage/Exceptions/FileUploadExceptionTest.php (1)

1-25: ⚠️ Potential issue | 🟡 Minor

Re-run PHP CS Fixer before merge.

The assertions look in line with the exception factories, but CI is still failing this file on PHP CS Fixer.

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

In `@tests/Unit/Storage/Exceptions/FileUploadExceptionTest.php` around lines 1 -
25, Re-run the project's PHP CS Fixer on the test file and fix any style issues
so it passes CI: run the formatter against the file containing the
FileUploadExceptionTest class (methods testFileTypeNotAllowed and
testIncorrectMimeTypesConfig) and ensure formatting/spacing/braces follow the
repository rules; verify resulting file compiles and assertions referencing
FileUploadException factory methods still match after formatting.
tests/Unit/View/Exceptions/ViewExceptionTest.php (1)

1-29: ⚠️ Potential issue | 🟡 Minor

Re-run PHP CS Fixer before merge.

The coverage is correct, but CI is still reporting this file as not CS-compliant.

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

In `@tests/Unit/View/Exceptions/ViewExceptionTest.php` around lines 1 - 29, Re-run
PHP CS Fixer and apply the project coding standards to this test file (class
ViewExceptionTest and its methods testNoLayoutSet and testViewNotRendered) so it
becomes CS-compliant; run the configured php-cs-fixer command (or your
pre-commit formatter) against this file and commit the resulting formatting
changes (spacing, imports, and PSR-12 style fixes) before merging.
🧹 Nitpick comments (1)
src/Loader/Exceptions/LoaderException.php (1)

21-26: Fix mismatched class name in docblock.

At Line 22, the docblock says DatabaseException class, but this class is LoaderException. Please correct it to avoid misleading generated docs.

Suggested patch
- * DatabaseException class
+ * Class LoaderException
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Loader/Exceptions/LoaderException.php` around lines 21 - 26, The docblock
above the LoaderException class incorrectly labels it "DatabaseException class";
update the docblock summary to correctly refer to LoaderException so generated
docs match the class. Locate the docblock for the LoaderException class in
LoaderException.php and replace the "DatabaseException class" text with
"LoaderException class" (or an appropriate description referencing
LoaderException) so the class name and docblock are consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Captcha/Exceptions/CaptchaException.php`:
- Around line 21-24: Update the docblock to accurately reflect the defined class
name: change the line that reads "Class CacheException" to "Class
CaptchaException" in the CaptchaException class file so the docblock matches the
actual class (CaptchaException) and keep the `@package` and other annotations
unchanged.

In `@tests/Unit/App/Exceptions/AppExceptionTest.php`:
- Around line 1-18: Run the project's PHP formatter on the new test file to
apply coding standards fixes: open the AppExceptionTest class
(tests/Unit/App/Exceptions/AppExceptionTest.php) and run the repository's
formatter (e.g., php-cs-fixer fix or composer run format) so the
testMissingAppKeyFactory method and surrounding whitespace/formatting are
adjusted to the project's CS rules; commit the formatted file so CI no longer
reports PHP CS Fixer violations.

In `@tests/Unit/App/Exceptions/BaseExceptionTest.php`:
- Around line 1-61: Run php-cs-fixer on the changed test file (the
BaseExceptionTest and BaseExceptionStub definitions and their test methods such
as testMethodNotSupportedFactory, testAdapterAndDriverFactories,
testLookupAndConnectionFactories, testConfigAndRequestMethodFactories) to
normalize formatting/whitespace according to project rules, apply the fixes it
suggests, stage the updated file and re-run the test/CI pipeline so the PHP CS
Fixer violations are resolved before merging.

In `@tests/Unit/Asset/Exceptions/AssetExceptionTest.php`:
- Around line 1-27: Formatter fixes are required for AssetExceptionTest: run the
project's PHP CS Fixer (or php-cs-fixer fix) and apply its changes to the
AssetExceptionTest class so the file adheres to coding standards; ensure
spacing, imports, and line endings are corrected for the class
AssetExceptionTest and its methods testPositionInUse and testNameInUse and
commit the formatted file.

In `@tests/Unit/Auth/Exceptions/AuthExceptionTest.php`:
- Around line 1-44: Run PHP-CS-Fixer on the test file and commit the formatting
fixes so CI passes: apply PSR-12 formatting (or your project's php-cs-fixer
config) to tests/Unit/Auth/Exceptions/AuthExceptionTest.php — e.g., run
vendor/bin/php-cs-fixer fix (or your project equivalent) and commit the updated
file; ensure the AuthExceptionTest class (and its test methods like
testIncorrectCredentials, testInactiveAccount, etc.) are formatted according to
the fixer rules.

In `@tests/Unit/Config/Exceptions/ConfigExceptionTest.php`:
- Around line 1-18: The test file ConfigExceptionTest (class
ConfigExceptionTest, method testConfigCollision) is failing PHP CS Fixer; run
the project's formatter (e.g., php-cs-fixer fix . or the repository's configured
formatter command) against this file, apply the fixer output, and commit the
reformatted ConfigExceptionTest.php so it complies with PHP CS Fixer rules
before merging.

In `@tests/Unit/Encryption/Exceptions/CryptorExceptionTest.php`:
- Around line 1-36: The file CryptorExceptionTest contains PHP CS Fixer
formatting violations; run php-cs-fixer (or your project's pre-commit formatter)
against this file or the whole repo to normalize formatting, then commit the
updated file so the class CryptorExceptionTest and its test methods
(testPublicKeyNotProvided, testPrivateKeyNotProvided, testInvalidCipher) pass CI
linting; ensure you stage the formatted changes before pushing.

In `@tests/Unit/Hasher/Exceptions/HasherExceptionTest.php`:
- Around line 1-25: This file fails PHP CS Fixer rules; run php-cs-fixer (e.g.,
php-cs-fixer fix) and reformat the test class HasherExceptionTest so it complies
with project coding standards — ensure spacing, indentation, imports and
trailing newlines are fixed for the class and its methods
testAlgorithmNotSupported and testInvalidBcryptCost, then re-run tests/CI to
confirm the style violations are resolved.

In `@tests/Unit/Hook/Exceptions/HookExceptionTest.php`:
- Around line 1-27: Run PHP-CS-Fixer on this test file to normalize formatting
before merging; specifically apply the project's coding style to
HookExceptionTest (affecting methods testHookDuplicateName and
testUnregisteredHookName) and ensure spacing/line breaks and phpdoc/namespace
formatting conform to the fixer rules so the assertions around
HookException::hookDuplicateName and HookException::unregisteredHookName remain
unchanged, then commit the formatted file.

In `@tests/Unit/HttpClient/Exceptions/HttpClientExceptionTest.php`:
- Around line 1-18: Run the project's PHP CS Fixer/formatter and commit the
resulting changes for this test file: format
tests/Unit/HttpClient/Exceptions/HttpClientExceptionTest.php (the class
HttpClientExceptionTest and method testRequestNotCreated) so it adheres to the
repo coding standards; specifically run the configured fixer (e.g., php-cs-fixer
fix or composer run format), review and stage the updated file, and push the
formatted file so CI no longer reports style violations.

In `@tests/Unit/Jwt/Exceptions/JwtExceptionTest.php`:
- Around line 1-18: Run the PHP formatter/CS fixer and apply its changes to this
test file: open the JwtExceptionTest class and the testPayloadNotFound method,
run your project's PHP CS Fixer (e.g., php-cs-fixer fix or composer cs:fix) to
reformat according to the repo rules, review the modified JwtExceptionTest.php
to ensure spacing/imports follow the fixer output, and commit the formatted file
so CI no longer flags the file as non-compliant.

In `@tests/Unit/Lang/Exceptions/LangExceptionTest.php`:
- Around line 1-27: Run the PHP CS Fixer/formatter over the test file and commit
the fixed formatting so CI passes: open the LangExceptionTest class (methods
testTranslationsNotFound and testMisconfiguredDefaultConfig) and apply your
project formatter (e.g., run vendor/bin/php-cs-fixer fix
tests/Unit/Lang/Exceptions/LangExceptionTest.php or the repository's configured
php cbf/php-cs-fixer command), then stage the modified file and push the commit
containing only the formatting changes.

In `@tests/Unit/Logger/Exceptions/LoggerExceptionTest.php`:
- Around line 1-27: The file LoggerExceptionTest (class LoggerExceptionTest with
methods testLogPathIsNotDirectory and testLogPathIsNotFile) fails PHP-CS-Fixer
checks; run the project's php-cs-fixer configuration against this file (or run
the repo-wide fixer) to normalize formatting, then stage the formatted changes
and update the PR so CI passes — ensure you do not change test logic, only
formatting/PSR rules that php-cs-fixer enforces.

In `@tests/Unit/Middleware/Exceptions/MiddlewareExceptionTest.php`:
- Around line 1-18: The file MiddlewareExceptionTest::testMiddlewareNotFound is
failing PHP CS Fixer; run your formatter (e.g., vendor/bin/php-cs-fixer fix
tests/Unit/Middleware/Exceptions/MiddlewareExceptionTest.php or the project's
configured fixer) and commit the resulting changes so the file follows the
project's coding standards (apply PSR-12 spacing, use statement ordering,
trailing newline, and any other fixer edits) before merging.

In `@tests/Unit/Migration/Exceptions/MigrationExceptionTest.php`:
- Around line 1-45: The test file MigrationExceptionTest has PHP CS Fixer
formatting issues; run php-cs-fixer (e.g. php-cs-fixer fix) on the file
containing class MigrationExceptionTest and its test methods
(testWrongDirection, testUnsupportedAction, testNothingToMigrate,
testInvalidMigrationClass), apply the suggested formatting fixes, and commit the
corrected file so CI no longer fails on PHP CS Fixer violations.

In `@tests/Unit/Module/Exceptions/ModuleExceptionTest.php`:
- Around line 1-58: The file ModuleExceptionTest contains PHP CS Fixer style
violations; run php-cs-fixer (or your project's formatting command) against this
file (or the whole repository) and commit the reformatted output so tests pass
CI; specifically reformat the class ModuleExceptionTest and its methods (e.g.,
testModuleRoutesNotFound, testModuleConfigNotFound,
testModuleCreationIncomplete, testMissingModuleTemplate,
testMissingModuleDirectory, testModuleAlreadyExists, testDirectoryListingFailed)
to conform to the project's PHP CS Fixer rules before merging.

In `@tests/Unit/Paginator/Exceptions/PaginatorExceptionTest.php`:
- Around line 1-18: The test file PaginatorExceptionTest (method
testMissingRequiredParams) is failing PHP CS Fixer/formatter checks; run the
project's code formatter (e.g., php-cs-fixer or the repo's preconfigured
formatter) on that file or across the repo and apply the changes so the file
complies with the coding standards — then re-run tests/CI, ensuring
PaginatorExceptionTest and its assertions remain unchanged while only
whitespace/formatting are corrected.

In `@tests/Unit/Router/Exceptions/RouteExceptionTest.php`:
- Around line 10-34: Add assertions that verify the PHP error code (getCode())
for every RouteException factory used in this test: for each call to
RouteException::{incompleteControllerRoute, nestedGroups,
middlewaresOutsideRoute, controllerWithoutModule, cacheableOutsideRoute,
closureHandlerMissing, notClosure, nameBeforeDefinition, paramNameNotValid,
moduleRoutesNotClosure, nonUniqueNameInModule, actionNotFound,
invalidHandlerResponse, paramNameNotAvailable} add an
assertSame(<expected_code>, RouteException::...()->getCode()) following the
existing pattern used for noHttpMethods() and closureWithController(); determine
the correct expected code (E_ERROR or E_WARNING) by checking the corresponding
constants in the RouteException implementation and use that value in the
assertion.

---

Outside diff comments:
In `@tests/Unit/Csrf/Exceptions/CsrfExceptionTest.php`:
- Around line 1-29: This test file isn’t PHP-CS-Fixer compliant; run the
project's PHP CS Fixer (or the configured linter) and apply the automatic fixes
to CsrfExceptionTest (ensure file header spacing, indentation, blank lines
between methods, and PSR-12 conforming braces/whitespace in the class and
methods testTokenNotFound and testTokenNotMatched are corrected) so the file
matches the repo coding standards before merging.

In `@tests/Unit/Di/Exceptions/DiExceptionTest.php`:
- Around line 1-53: Re-run PHP CS Fixer (using the project config) and apply
fixes to this test file so it meets coding standards; run the fixer (e.g.
php-cs-fixer fix . --config=.php_cs.dist) or your repo's configured command,
then re-check and commit the updated DiExceptionTest.php changes (class
DiExceptionTest and its test methods testDependencyFactories,
testAbstractAndCircularFactories, testInvalidCallableFactory) before merging so
CI no longer flags CS violations.

In `@tests/Unit/Environment/Exceptions/EnvExceptionTest.php`:
- Around line 1-29: This test file (EnvExceptionTest class, methods
testEnvironmentImmutable and testEnvironmentNotLoaded) is not PHP CS Fixer
compliant; re-run php-cs-fixer (or the project's fixer command) on this file to
fix formatting/spacing/namespace/import order and ensure it follows PSR-12 so
the file passes CI linting before merging.

In `@tests/Unit/Session/Exceptions/SessionExceptionTest.php`:
- Around line 1-29: Run PHP CS Fixer on the tests file and fix formatting issues
in the SessionExceptionTest class (SessionExceptionTest, testSessionNotStarted,
testSessionNotDestroyed) so it complies with project coding standards; re-run
the fixer until no changes are suggested and commit the formatted file.

In `@tests/Unit/Storage/Exceptions/FileSystemExceptionTest.php`:
- Around line 1-32: Run PHP CS Fixer to make this test file comply with project
coding standards; specifically reformat tests in the FileSystemExceptionTest
class (methods testDirectoryNotExists, testDirectoryNotWritable,
testFileAlreadyExists) by running the project's php-cs-fixer configuration
(e.g., php-cs-fixer fix) and commit the resulting whitespace/formatting changes
so CI passes.

In `@tests/Unit/Storage/Exceptions/FileUploadExceptionTest.php`:
- Around line 1-25: Re-run the project's PHP CS Fixer on the test file and fix
any style issues so it passes CI: run the formatter against the file containing
the FileUploadExceptionTest class (methods testFileTypeNotAllowed and
testIncorrectMimeTypesConfig) and ensure formatting/spacing/braces follow the
repository rules; verify resulting file compiles and assertions referencing
FileUploadException factory methods still match after formatting.

In `@tests/Unit/View/Exceptions/ViewExceptionTest.php`:
- Around line 1-29: Re-run PHP CS Fixer and apply the project coding standards
to this test file (class ViewExceptionTest and its methods testNoLayoutSet and
testViewNotRendered) so it becomes CS-compliant; run the configured php-cs-fixer
command (or your pre-commit formatter) against this file and commit the
resulting formatting changes (spacing, imports, and PSR-12 style fixes) before
merging.

---

Nitpick comments:
In `@src/Loader/Exceptions/LoaderException.php`:
- Around line 21-26: The docblock above the LoaderException class incorrectly
labels it "DatabaseException class"; update the docblock summary to correctly
refer to LoaderException so generated docs match the class. Locate the docblock
for the LoaderException class in LoaderException.php and replace the
"DatabaseException class" text with "LoaderException class" (or an appropriate
description referencing LoaderException) so the class name and docblock are
consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9d9697c1-1ed4-41c9-8352-c75c5f09ff13

📥 Commits

Reviewing files that changed from the base of the PR and between b4577ba and 8bd7838.

📒 Files selected for processing (44)
  • src/Auth/Enums/AuthKeys.php
  • src/Cache/Exceptions/CacheException.php
  • src/Captcha/Exceptions/CaptchaException.php
  • src/Cron/Enums/ExceptionMessages.php
  • src/Database/Enums/Key.php
  • src/Database/Enums/Relation.php
  • src/Database/Enums/Type.php
  • src/Environment/Enums/Env.php
  • src/Http/Enums/ContentType.php
  • src/Http/Enums/StatusCode.php
  • src/Http/Exceptions/HttpException.php
  • src/Loader/Exceptions/LoaderException.php
  • src/Mailer/Exceptions/MailerException.php
  • src/Paginator/Enums/Pagination.php
  • src/Renderer/Exceptions/RendererException.php
  • src/ResourceCache/Exceptions/ResourceCacheException.php
  • src/Service/Exceptions/ServiceException.php
  • tests/Unit/App/Exceptions/AppExceptionTest.php
  • tests/Unit/App/Exceptions/BaseExceptionTest.php
  • tests/Unit/Archive/Exceptions/ArchiveExceptionTest.php
  • tests/Unit/Asset/Exceptions/AssetExceptionTest.php
  • tests/Unit/Auth/Exceptions/AuthExceptionTest.php
  • tests/Unit/Config/Exceptions/ConfigExceptionTest.php
  • tests/Unit/Csrf/Exceptions/CsrfExceptionTest.php
  • tests/Unit/Database/Exceptions/DatabaseExceptionTest.php
  • tests/Unit/Di/Exceptions/DiExceptionTest.php
  • tests/Unit/Encryption/Exceptions/CryptorExceptionTest.php
  • tests/Unit/Environment/Exceptions/EnvExceptionTest.php
  • tests/Unit/Hasher/Exceptions/HasherExceptionTest.php
  • tests/Unit/Hook/Exceptions/HookExceptionTest.php
  • tests/Unit/HttpClient/Exceptions/HttpClientExceptionTest.php
  • tests/Unit/Jwt/Exceptions/JwtExceptionTest.php
  • tests/Unit/Lang/Exceptions/LangExceptionTest.php
  • tests/Unit/Logger/Exceptions/LoggerExceptionTest.php
  • tests/Unit/Middleware/Exceptions/MiddlewareExceptionTest.php
  • tests/Unit/Migration/Exceptions/MigrationExceptionTest.php
  • tests/Unit/Model/Exceptions/ModelExceptionTest.php
  • tests/Unit/Module/Exceptions/ModuleExceptionTest.php
  • tests/Unit/Paginator/Exceptions/PaginatorExceptionTest.php
  • tests/Unit/Router/Exceptions/RouteExceptionTest.php
  • tests/Unit/Session/Exceptions/SessionExceptionTest.php
  • tests/Unit/Storage/Exceptions/FileSystemExceptionTest.php
  • tests/Unit/Storage/Exceptions/FileUploadExceptionTest.php
  • tests/Unit/View/Exceptions/ViewExceptionTest.php

Comment thread src/Captcha/Exceptions/CaptchaException.php
Comment thread tests/Unit/App/Exceptions/AppExceptionTest.php
Comment thread tests/Unit/App/Exceptions/BaseExceptionTest.php
Comment thread tests/Unit/Asset/Exceptions/AssetExceptionTest.php
Comment thread tests/Unit/Auth/Exceptions/AuthExceptionTest.php
Comment thread tests/Unit/Middleware/Exceptions/MiddlewareExceptionTest.php
Comment thread tests/Unit/Migration/Exceptions/MigrationExceptionTest.php
Comment thread tests/Unit/Module/Exceptions/ModuleExceptionTest.php
Comment thread tests/Unit/Paginator/Exceptions/PaginatorExceptionTest.php
Comment thread tests/Unit/Router/Exceptions/RouteExceptionTest.php
@codecov

codecov Bot commented Apr 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.28%. Comparing base (b4577ba) to head (6efc846).
⚠️ Report is 30 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #484      +/-   ##
============================================
+ Coverage     83.19%   85.28%   +2.09%     
  Complexity     2903     2903              
============================================
  Files           249      249              
  Lines          7651     7651              
============================================
+ Hits           6365     6525     +160     
+ Misses         1286     1126     -160     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@armanist armanist added this to the 3.0.0 milestone Apr 29, 2026
@armanist armanist merged commit 590e4b5 into quantum-php:master Apr 29, 2026
7 checks passed
@armanist armanist deleted the issue/481-enum-exception-coverage branch April 29, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Normalize enum/exception coverage conventions

1 participant