testing php applications

API Testing With Postman, Bruno, Newman, And cURL

API tools complement application tests. cURL is excellent for a direct reproducible request. Postman and Bruno can organise collections and environments. Newman runs Postman collections from the command line for CI workflows.

Keep Requests Reproducible

Record method, URL, headers, body, expected status, and stable response checks. Keep tokens and environment-specific credentials outside committed collections.

Use Collections For Workflows

Collections are useful for smoke checks and shared exploration. They do not replace PHP tests around domain rules, database behaviour, or internal services.

curl --fail-with-body \
  --header 'Accept: application/json' \
  http://localhost:8080/api/products/42

Common Mistakes

  • Committing real tokens in collection files.
  • Checking only status 200.
  • Treating a collection as the entire automated test strategy.
  • Running destructive requests against the wrong environment.

What To Practise

  • Reproduce an API request with cURL.
  • Use collections for shared workflows.
  • Run suitable collections in CI.

Practice

Practice: Describe A Product API Smoke Check

Create a smoke-check outline for a product API.

Requirements

  • Request one known product.
  • Check status and stable fields.
  • Keep credentials external.
  • Include a missing-product request.
Show solution

The smoke check is deliberately small.

curl --fail-with-body \
  --header 'Accept: application/json' \
  http://localhost:8080/api/products/42

curl --header 'Accept: application/json' \
  http://localhost:8080/api/products/999999

Add collection assertions for stable JSON fields and run the exported collection with the tool appropriate to the repository.