api-platform-tests

Installation
SKILL.md

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().
Installs
64
GitHub Stars
224
First Seen
Sep 18, 2026