mcpField
A
api-platform-tests

api-platform-tests

github.com/dev-toolingsTesting & quality22778 installsUpdated 3w ago
Repository

About api-platform-tests

A Symfony-oriented skill for writing functional tests of API Platform endpoints. It covers database setup, authentication, response assertions, and common failure paths.

Key features

  1. 01Endpoint CRUD tests
  2. 02Validation and access-control assertions
  3. 03Filter and pagination checks
  4. 04Database reset and factory setup
  5. 05JSON schema assertions

Use cases

  1. 01Testing collection and item endpoints
  2. 02Verifying 401, 403, 404, and 422 responses
  3. 03Checking filters and pagination
  4. 04Seeding isolated test data

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/dev-toolings/superpowers-symfony --skill api-platform-tests

After installing, type/api-platform-testsin Claude Code to confirm it loaded.

Bundled filesreference.md

Details

From the project README

Api Platform Tests (Symfony)

Use when

  • Writing functional tests for API Platform endpoints: collection, item, create, update, delete.
  • Asserting validation errors (422) and access control (401, 403).
  • Checking filters, pagination, or the JSON schema of responses.
  • Setting up a clean database and test data for API tests.

Default workflow

  1. Extend ApiTestCase and seed data with Foundry factories (createOne, createMany).
  2. Reset state with #[ResetDatabase] and the Factories trait, with DAMA rolling back each test.
  3. Call static::createClient()->request() and assert the status code, content type, and assertJsonContains().
  4. Authenticate with auth_bearer and cover the anonymous, owner, and other-user cases.
  5. Assert member and totalItems for filters and pagination (hydra:-prefixed only with hydra_prefix: true).
  6. Assert the shape with assertMatchesResourceItemJsonSchema() and assertMatchesResourceCollectionJsonSchema().

Guardrails

  • Send PATCH with the application/merge-patch+json content type.
  • #[ResetDatabase] needs PHPUnit 10+ and Foundry 2.9: use the ResetDatabase trait on PHPUnit 9.
  • Cover the failure paths too: 404, 422, 401, 403. A type error on a constrained property is 422 in 5.0 but 400 in 4.4 and earlier.
  • Read the configured items per page rather than hardcoding a page size in assertions.

Progressive disclosure

  • Use this file for execution posture and risk controls.
  • Open references when deep implementation details are needed.

Output contract

  • The test classes added and the endpoints they cover.
  • Factories and reset strategy used.
  • Test run output, including the failure paths.

References

  • reference.md

Comments

Markdown supported