Skip to content

#303 - Tests: detect the deprecations and boot a kernel - #304

Merged
njoubert-cleverage merged 1 commit into
mainfrom
303
Oct 20, 2026
Merged

njoubert-cleverage merged 1 commit into
mainfrom
303

Conversation

@njoubert-cleverage

@njoubert-cleverage njoubert-cleverage commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes #303. Same work as in the bridge bundles (cleverage/archive-process-bundle#42, cleverage/cache-process-bundle#60, cleverage/doctrine-process-bundle#61, cleverage/flysystem-process-bundle#62, cleverage/rest-process-bundle#66, cleverage/soap-process-bundle#59, cleverage/ui-process-bundle#184).

Deprecation detection

  • phpunit.xml.dist: failOnDeprecation and displayDetailsOnTestsThatTriggerDeprecations; <source ignoreSuppressionOfDeprecations="true">, so that the deprecations triggered with trigger_deprecation() (silenced @trigger_error()) are reported. No ignoreIndirectDeprecations: it also hides the DebugClassLoader deprecations about the classes of the bundle.
  • New tests/bootstrap.php: DebugClassLoader::enable() (extending a @final / @internal class, missing return types...).

Kernel test

  • New tests/App/TestKernel.php + tests/Functional/KernelTest.php (#[CoversNothing]): FrameworkBundle and this bundle, the container is compiled and:
    • every task of config/services/task.yaml (58 codes, read from the cleverage.task tags) resolves by its code through TaskRegistry, with its dependencies;
    • every transformer is resolved by TransformerRegistry;
    • a process (constant_output → transformer with sprintf) runs and returns its output.
  • The logger service of the test kernel is a NullLogger: the default logger of FrameworkBundle may print the process logs, which makes the test risky ("printed unexpected output").
  • KernelTest restores the exception handler of the ErrorHandler registered when the kernel boots, which the first Symfony 6.4 versions do not remove (risky test with the lowest dependencies).
  • TestKernel sets framework.property_info.with_constructor_extractor from Symfony 7.3 (not setting it is deprecated there); rector.php skips RemoveAlwaysTrueIfConditionRector for tests/App/TestKernel.php.

Deprecations revealed by the tests (tests only, no change in src/)

  • Tests using a deprecated feature whose deprecation is already checked by a dedicated test now ignore it, through a new tests/IgnoreDeprecationsTrait.php: RegistryCompilerPass (checked by testIsDeprecated()), the service option of the tasks (ConfigurationTest::testServiceIsDeprecated()), the additional_parameters option of CallbackTransformer (testAdditionalParametersAreDeprecated()).
  • DenormalizeTransformerTest::testCollectionClassIsSupported(): dates in the default format, symfony/serializer 8.1 deprecates parsing 2024-01-02 with the loose constructor.

Checked in the container (964 tests): highest dependencies (PHP 8.5, Symfony 8.1, PHPUnit 13), lowest dependencies (PHP 8.2, Symfony 6.4.0, PHPUnit 11.5), Symfony 6.4.48 on PHP 8.2 and 8.5, Symfony 7.4: no deprecation, no risky test (with pcov coverage); PHPStan, PHP-CS-Fixer and Rector OK. A deprecation makes PHPUnit exit with code 1.

Requirements

  • Documentation updates
    • Reference
    • Cookbooks
    • Changelog
  • Unit tests

Breaking changes

None: tests and CI only.

🤖 Generated with Claude Code

- PHPUnit fails on deprecations (failOnDeprecation, details displayed), the
  silenced ones included (ignoreSuppressionOfDeprecations). The new
  tests/bootstrap.php enables the Symfony DebugClassLoader (@Final,
  @internal, return types).
- New functional test booting a kernel (FrameworkBundle and this bundle):
  every task of config/services/task.yaml resolves by its code through
  TaskRegistry, every transformer is resolved by TransformerRegistry, and a
  process (constant_output -> transformer) runs. The logger is a NullLogger:
  the default logger of FrameworkBundle may print the process logs (risky
  test).
- The tests of a deprecated feature whose deprecation is checked by another
  test ignore it (new IgnoreDeprecationsTrait): RegistryCompilerPass, the
  "service" option of the tasks, the "additional_parameters" option of
  CallbackTransformer.
- DenormalizeTransformerTest: dates in the default format (symfony/serializer
  8.1 deprecates the loose parsing).
- The exception handler of the ErrorHandler registered at boot is restored
  after each kernel test (not removed by the first Symfony 6.4 versions);
  framework.property_info.with_constructor_extractor set from Symfony 7.3,
  condition kept by Rector.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@njoubert-cleverage
njoubert-cleverage merged commit 8dd61c4 into main Oct 20, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests: detect the deprecations and boot a kernel

1 participant