Skip to content

[TASK] Move TestExtension out of the shipped source - #1357

Open
CybotTM wants to merge 2 commits into
phpDocumentor:mainfrom
CybotTM:chore/move-test-extension
Open

[TASK] Move TestExtension out of the shipped source#1357
CybotTM wants to merge 2 commits into
phpDocumentor:mainfrom
CybotTM:chore/move-test-extension

Conversation

@CybotTM

@CybotTM CybotTM commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Moves TestExtension from packages/guides/src/ to packages/guides/tests/unit/. Pure rename, no content change.

Why

It is test infrastructure, not library code. process() forces Parser, Compiler and phpdoc.guides.output_node_renderer public so tests can pull them from the container, replaces the clock with MockClock pinned to 2023-01-01 12:00:00, and registers Monolog's TestHandler so functional tests can assert on log records. Its only user is tests/ApplicationTestCase.php, from which tests/Functional/FunctionalTest.php and tests/Integration/IntegrationTest.php inherit. No packages/*/src references it.

It reached this package by accident rather than by decision. 1d10cbd8 created it in packages/guides-symfony/src/DependencyInjection/ next to the new ContainerFactory, wiring it into ApplicationTestCase in the same commit. 54daa48f dissolved guides-symfony the next day, and the rename carried the file into packages/guides. ba041eb8 then added the Monolog handler and 541fbf4d the mocked clock, each without revisiting where the class lives, and the "make all classes final" sweep in a7395d07 treated it as ordinary library code.

The effect is that phpdocumentor/guides ships a class using Monolog\Logger, Monolog\Handler\TestHandler and Symfony\Component\Clock\MockClock as production symbols, none of which the package requires. That is one of the items in #1355.

Why this is safe

The fully qualified name is unchanged. packages/guides/tests/unit/ maps to the same phpDocumentor\Guides\ namespace as src/, and the root autoload-dev already lists that path, so no import, no consumer and no configuration changes. Because every package marks /tests export-ignore, the class simply stops being part of the published phpdocumentor/guides.

The one visible change for a consumer: anyone who pulled phpDocumentor\Guides\DependencyInjection\TestExtension out of the published package to test their own extension would lose it. It is undocumented and appears in no guide, so this looks unintended rather than a supported entry point — worth a second opinion if you disagree.

Verification

Full suite 828 tests, no failures. PHPStan and PHPCS clean.

Assisted by claude-code:claude-fable-5 — Session

@CybotTM
CybotTM marked this pull request as ready for review August 19, 2026 20:09
TestExtension is test infrastructure: it forces Parser, Compiler and the
output node renderer public so tests can pull them from the container, pins
the clock to a fixed date with MockClock, and registers Monolog's TestHandler
so functional tests can assert on log records. Its only user is
tests/ApplicationTestCase.php.

It reached packages/guides by accident rather than by decision. It was created
in packages/guides-symfony alongside ContainerFactory (1d10cbd), and that
package was dissolved the next day, so the rename carried it into
packages/guides (54daa48). Later commits added the Monolog handler (ba041eb)
and the mocked clock (541fbf4) without anyone revisiting where it lives.

The fully qualified name does not change: packages/guides/tests/unit maps to
the same phpDocumentor\Guides namespace, and the root autoload-dev already
covers that path, so no import or consumer is touched. Because every package
marks /tests export-ignore, the class now stays out of the published
phpdocumentor/guides, and with it Monolog and MockClock as production symbols.

Refs phpDocumentor#1355

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Assisted-by: claude-code:claude-fable-5
Agent-Session: https://claude.ai/code/session_0114KJz3vqq2WWfx4FUdmcss
Agent-Host: 0493f0
@CybotTM
CybotTM force-pushed the chore/move-test-extension branch from 16a5c91 to d8c5cc0 Compare August 20, 2026 11:57
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.

2 participants