# API Testing

> Create and execute API test suites for REST APIs. Use when asked to test endpoints, validate API responses, or create API test plans. Use when this capability is needed.

- Skill: `tomevault-io/api-testing-6` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/api-testing-6`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/api-testing-6/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/api-testing-6

---


# API Testing

## Overview

Create comprehensive API test suites for REST APIs. Covers endpoint testing, response validation, authentication flows, error handling, and performance benchmarks.

## Test Structure

### 1. Setup
```php
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://api.example.com',
    'timeout' => 30,
    'headers' => ['Accept' => 'application/json'],
]);
```

### 2. Request Testing
- Test all HTTP methods (GET, POST, PUT, PATCH, DELETE)
- Validate request headers
- Test query parameters
- Test request body formats (JSON, form-data, multipart)

### 3. Response Validation
- Status code verification
- Response body schema validation
- Header validation (Content-Type, Cache-Control, etc.)
- Response time assertions

### 4. Authentication Testing
- Valid credentials
- Invalid credentials
- Expired tokens
- Missing authentication
- Role-based access control

### 5. Error Handling
- 400 Bad Request (invalid input)
- 401 Unauthorized
- 403 Forbidden
- 404 Not Found
- 422 Unprocessable Entity
- 429 Too Many Requests
- 500 Internal Server Error

### 6. Edge Cases
- Empty request bodies
- Extremely large payloads
- Special characters in parameters
- Concurrent requests
- Timeout scenarios

## Output Format

Generate PHPUnit test classes with:
- Descriptive test method names
- Data providers for parameterized tests
- setUp/tearDown for test fixtures
- Proper assertions for each scenario

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/claude-php) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

