Problem/Motivation

Two risks of this work are known: the generator silently changing the API, and logic leaking into generated files, which would turn every site running it into a generated fork. Both are testable, and neither is caught by testing the responses alone.

Proposed resolution

  • Golden files: generate from the fixture model and compare byte for byte with a committed expected output, so any change to a template is visible in review.
  • A test that parses every generated class and fails on a conditional, a loop or a service call in it — the rule of "declarations only" enforced mechanically.
  • A test that the generated code passes the project's PHPCS and PHPStan.
  • A test that generating twice produces no diff.

Remaining tasks

Everything.

Issue fork myrest-3621997

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sergeydruua created an issue. See original summary.

  • sergeydruua committed 72de1a60 on 1.0.x
    Issue #3621997: Assert the generator output against a golden fixture and...
sergeydruua’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

sergeydruua’s picture

Status: Fixed » Closed (fixed)