Testing APIs written in PHP using the Behat feature testing tool
summary
Uses Behat and Gherkin to run real HTTP requests against a Symfony app and a real database, not unit mocks, so tests catch config and serialization mistakes. Examples include a delete-task scenario that asserts status and database persistence, JSON schema checks that use additionalProperties false to catch accidental leaks, security checks that expect 401 or 404, and a setup that runs about 15,000 steps across 1,000+ scenarios in ~5.5 minutes. Built demo to-do app works end to end.
AI-written summary · about
chapters (23)
- 0:00API testing with Behat
- 1:16What is Behat
- 3:02Writing feature tests
- 5:54API responses and DB state
- 7:39JSON schema validation
- 9:09Security checks
- 10:56Scenario outlines
- 11:59Tags and hooks
- 14:31Background steps
- 15:17Behat for API testing
- 17:03Best practices
- 18:09Q&A: Complex endpoints
- 20:19Q&A: Mocking services
- 21:23Q&A: Writing test steps
- 22:47Q&A: HTTP kernel tests
- 26:01Q&A: Performance handling
- 27:25Q&A: Mocking Symfony deps
- 28:26Q&A: Dynamic fixtures
- 29:50Q&A: DB transactions
- 30:13Q&A: Testable steps
- 31:19Q&A: Debugging failures
- 31:40Q&A: Product owners
- 32:47Q&A: Symfony config
related talks
31mTesting API's written in PHP using the Behat feature testing tool
27mAutomated Web Acceptance Testing with Behat
45mBehat for characterisation on tests
45mUsing Behat as a Webapp Automation Tool
26mBehaviour Driven Development with Laravel
50mBuilding Testable PHP Applications
45mBehat from 0 to Hero: a Practical Guide
49mTesting for the Brave and True
