Skip to main content
skill CX Codex

api-platform-tests — Claude Code skill for API Platform tests

The api-platform-tests skill guides functional tests for Symfony API Platform resources, including response checks, filters, JSON schemas, and access control. Use it while building or changing API endpoints.

MIT ★ 234 updated 2026-10-05

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add dev-toolings/superpowers-symfony --skill api-platform-tests -a claude-code
Open on GitHub

What api-platform-tests does

The skill lays out a testing flow for API Platform endpoints with ApiTestCase: prepare data with Foundry factories, send a request, then check its status, content type, and JSON response. It covers collections and individual resources, CRUD operations, validation failures, and access control.

Tests can reset state with #[ResetDatabase] and use Factories. Authentication checks use auth_bearer; filter and pagination assertions inspect member and totalItems, while resource JSON schema assertions check response shape. A PATCH request needs the application/merge-patch+json content type.

There are version-specific details. #[ResetDatabase] requires PHPUnit 10+ and Foundry 2.9; on PHPUnit 9, use the ResetDatabase trait. A type error on a constrained property returns 422 in API Platform 5.0, but 400 in 4.4 and earlier. Match the expected status in the test to the version in the project.

What it helps with

  • check collection and individual resource responses
  • cover API resource creation, updates, and deletion
  • test validation failures and access restrictions
  • verify filters and pagination results
  • match responses against resource JSON schemas

Example prompts for the agent

  • Write ApiTestCase functional tests for an API Platform collection and its individual resources.
  • Add filter and pagination tests that inspect member and totalItems.
  • Cover anonymous access, the owner, and another user, including access failures.

How to install api-platform-tests

1Skills CLI (Vercel)

npx skills add dev-toolings/superpowers-symfony --skill api-platform-tests -a claude-code

2Manually: put the files in place

~/.claude/skills/api-platform-tests/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/api-platform-tests/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about api-platform-tests

How do I install api-platform-tests in Claude Code?

Run npx skills add dev-toolings/superpowers-symfony --skill api-platform-tests -a claude-code. The skill is available at ~/.claude/skills/api-platform-tests/SKILL.md.

What does api-platform-tests do?

It guides functional tests for Symfony API Platform endpoints, with checks for filters, pagination, response schemas, authentication, and failure cases.

Which versions are required for #[ResetDatabase]?

The attribute requires PHPUnit 10+ and Foundry 2.9. For PHPUnit 9, use the ResetDatabase trait instead.

Source text

SKILL.md · MIT
---
name: api-platform-tests
description: Test API Platform resources with ApiTestCase; assert collections, items, filters, JSON schema, and authentication
capabilities: [read, search, edit, shell]
tags: [api-platform, testing]
# projected by `bun run build` — do not edit by hand
allowed-tools:
  - Read
  - Glob
  - Grep
  - Write
  - Edit
  - Bash
---

# 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`

© dev-toolings · MIT · dev-toolings/superpowers-symfony

Similar skills

All skills for Backend and APIs →

From the same set51

The whole set →
interfaces-and-autowiring interfaces-and-autowiring guides Symfony dependency injection in Claude Code by binding interfaces, configuring #[Target] aliases, and decorating services cleanly. CX Codex +1 ★ 234repo stars symfony-cache Configure Symfony Cache pools, entry expiry, and tag-based invalidation with this skill. It helps when caching costly reads or preventing a burst of recomputations after a key expires. CX Codex +1 ★ 234repo stars test-doubles-mocking test-doubles-mocking — a skill for creating test doubles with PHPUnit mocks in Symfony, used to replace slow or external dependencies, verify method calls, and write simplified repository fakes in isolated unit tests. CX Codex +1 ★ 234repo stars rate-limiting rate-limiting guides Claude Code through setting up Symfony RateLimiter policies, controller attributes, and 429 responses with Retry-After headers. CX Codex +1 ★ 234repo stars api-platform-serialization Skill configures API Platform serialization: field groups per operation, IRIs instead of nested objects, computed properties, and normalizer options. CX Codex +1 ★ 234repo stars symfony-scheduler Configures recurring tasks with the Symfony Scheduler component without system crontab entries. Useful for scheduled report generation, database cleanups, and Messenger syncs. CX Codex +1 ★ 234repo stars tdd-with-pest tdd-with-pest guides RED-GREEN-REFACTOR in Symfony projects using Pest v4. Use it to write new tests, reproduce bugs before a fix, or move PHPUnit tests to Pest syntax. CX Codex +1 ★ 234repo stars api-platform-versioning api-platform-versioning keeps API Platform clients alive through renames and removals: deprecation with a sunset date first, parallel versions as the last resort. CX Codex +1 ★ 234repo stars

Project sponsors

Companies that keep this analytics open