Skip to content

docs(claude+tests): codify test-comment and Symfony-defer practices#74

Merged
martinyde merged 4 commits into
developfrom
chore/test-method-comments
Jun 19, 2026
Merged

docs(claude+tests): codify test-comment and Symfony-defer practices#74
martinyde merged 4 commits into
developfrom
chore/test-method-comments

Conversation

@martinydeAI

Copy link
Copy Markdown
Collaborator

Links to issues

No issue — follow-up to the comment style introduced in
PR #72, bringing every
other test method in the project under the same convention.

Description

Adds a single-line // Tests …, // Ensures …, or // Verifies …
comment above every test method that didn't already have one. Each
comment names what the test asserts so a reader can scan a test
file's table of contents without reading the bodies.

Touches every test file in the project:

File Methods commented
tests/Integration/Command/UserChangePasswordCommandTest.php 2
tests/Integration/Command/UserCreateCommandTest.php 2
tests/Integration/Controller/AssistantControllerTest.php 3
tests/Integration/Controller/FrontpageControllerTest.php 2
tests/Integration/Controller/SecurityControllerTest.php 5
tests/Integration/Repository/AssistantRepositoryTest.php 1
tests/Integration/Repository/UserRepositoryTest.php 2
tests/Integration/Security/UserManagerTest.php 7
tests/Integration/SmokeTest.php 1
tests/Unit/DataFixtures/AssistantFixturesTest.php 2
tests/Unit/DataFixtures/UserFixturesTest.php 1
tests/Unit/Entity/AssistantTest.php 3
tests/Unit/Entity/UserTest.php 6
tests/Unit/KernelTest.php 1
tests/Unit/Twig/DevTemplateMarkerExtensionTest.php 3
tests/Unit/Twig/DevTemplateMarkerNodeVisitorTest.php 7
Total 48

The existing block-level docblock on KernelTest is kept and the
new one-liner sits beneath it. The docblock explains why the
override matters; the new line names what the test verifies.
Both audiences (skim-readers and people chasing rationale) are
served.

Screenshot of the result

N/A — documentation comments only, no rendered output changes.

Checklist

  • My code is covered by test cases.
  • My code passes our test (all our tests).
  • My code passes our static analysis suite.
  • My code passes our continuous integration process.

If your code does not pass all the requirements on the checklist you have to add a comment explaining why this change
should be exempt from the list.

Additional comments or questions

task test48 tests, 172 assertions pass.
task coding-standards-check → green.

Pure documentation change — no test logic, assertions, or
production code touched. The "covered by test cases" box stays
ticked because the tests themselves are the tests; the comment
addition doesn't introduce any new untestable code.

The five test files added on
PR #72
(QueryStringListTest, PageMetadataTest, CatalogCriteriaTest,
AssistantCatalogControllerTest, and the methods added to
AssistantRepositoryTest there) already follow this convention —
they were the trigger for adopting it project-wide.


Details - AI specificities

Goal and motivation

  • During review of PR #72
    the convention emerged of opening each test method with a
    one-line // Tests … / // Ensures … / // Verifies … comment.
    This PR backfills the same convention across every other test
    file already on develop so the project reads consistently from
    here on.

Scope

  • 48 one-line comments added across 16 test files.
  • No test logic changed. No assertions added or removed. No
    production code touched. No fixtures touched.

Non-goals

  • Not renaming any test methods. The new comments often
    paraphrase the existing method name in plainer prose — that's
    deliberate; the comment is for a reader scanning the file, not a
    rename trigger.
  • Not adding block-level docblocks. The convention is one-line
    comments only. Where a block docblock already exists
    (KernelTest), it stays and the one-liner sits beneath it.

Conventions applied

  • Each comment starts with // Tests …, // Ensures …, or
    // Verifies …. The verb choice is unbinding — pick whichever
    reads most naturally for the assertion in question.
  • One line, terse. Not a docblock, not a paragraph.
  • Placed immediately above the public function test… declaration.

Areas needing scrutiny

  • None substantive. Pure prose change; the suite passes byte-for-byte
    the same assertions it did before.

Follow-up work intentionally out of scope

  • None. Once this lands, every existing test method has the
    convention applied; future additions only need to follow it.

Related

  • PR #72 — introduced
    the convention; the test files added on that branch already
    follow it.

Each test method now opens with a single-line "Tests …", "Ensures …",
or "Verifies …" comment naming what the test asserts. The convention
mirrors the comments added to the catalogue PR's new test files and
applies the same treatment to every test method that pre-dated it.

Pure documentation change — no test logic touched, no assertions
added or removed. `task test` and `task coding-standards-check`
green. The existing block-level docblock on KernelTest is kept and
the one-line comment sits beneath it; both audiences (skim-readers
and people chasing the "why") are served.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Martin Yde Granath <yde001@gmail.com>
@martinyde martinyde requested a review from tuj June 18, 2026 06:38
martinydeAI and others added 2 commits June 18, 2026 08:47
…ntion

Carves a new top-level "Coding practices" section in CLAUDE.md and
moves the existing "Controllers stay thin" and "Service classes are
fully documented" subsections under it. Adds a third subsection
codifying the one-line `// Tests …` / `// Ensures …` /
`// Verifies …` comment convention that this PR applies across the
suite.

The split separates two kinds of rule:

- "Coding standards" stays the home for mechanically-enforced
  formatting (php-cs-fixer, twig-cs-fixer, prettier, markdownlint)
  plus the "Tests are not modified without approval" policy gate.
- "Coding practices" collects style conventions humans and agents
  follow on top of the linters — what a controller, service, or
  test method looks like in this codebase.

The "Tests are not modified" rule stays in "Coding standards"
because it's a policy / process gate (enforced via the
`guard-tests.sh` hook discussion in earlier sessions), not a style
convention. The new "Test methods carry a one-line intent comment"
rule is purely a style convention and lives in "Coding practices".

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Martin Yde Granath <yde001@gmail.com>
Adds a new "Defer to symfony.com/doc when implementing Symfony
features" subsection under Coding practices. When an agent (or a
human) adds or changes functionality that sits on top of a Symfony
component — controllers, routing, security, forms, validation,
Doctrine integration, console commands, messenger, mailer,
translation, asset mapping, Twig extensions, etc. — the rule is to
open the relevant chapter on symfony.com/doc first and follow the
documented approach.

Three operational sub-rules:

- When the docs offer multiple paths, pick the one that matches
  what's already in this codebase.
- When nothing comparable exists yet, prefer the most recent idiom
  shown in the docs (attribute-driven, autoconfigured, autowired).
- Cite the relevant doc URL in the PR description for any change
  that introduces a Symfony-component idiom for the first time.

Keeps the code in step with the framework instead of drifting into
bespoke shapes that look reasonable but miss built-in conventions.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Martin Yde Granath <yde001@gmail.com>
@martinyde martinyde changed the title chore(tests): add one-line intent comments above every test method docs(claude+tests): codify test-comment and Symfony-defer practices Jun 18, 2026
martinydeAI added a commit that referenced this pull request Jun 18, 2026
Applies the convention from PR #74 (CLAUDE.md "Test methods carry a
one-line intent comment") to the five test methods introduced for
#75. One line each, placed immediately above the method declaration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tuj
tuj previously approved these changes Jun 19, 2026
@martinyde martinyde merged commit b91aa5c into develop Jun 19, 2026
4 of 5 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.

3 participants