pushinbr / pam-http-testing
In-memory HTTP testing utilities for Pam applications.
Requires
- php: ^8.4
- pushinbr/pam-contracts: ^1.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Exercise your HTTP application without opening a socket.
In-memory requests and fluent response assertions for applications built with pushinbr/pam-http.
Install · Quick example · API · Docs · Issues
Install
Projects created with pam init my-api --template http already require it as a dev dependency. Elsewhere:
pam composer require --dev pushinbr/pam-http-testing
pam test
Quick example
<?php declare(strict_types=1); use Pam\App; use Pam\Http\Request; use Pam\Http\Response; use Pam\Http\Testing\TestClient; use PHPUnit\Framework\TestCase; final class ApplicationTest extends TestCase { public function test_ping_endpoint(): void { $app = new App(discoverPackages: false); $app->get('/api/ping', static fn (Request $request, Response $response): Response => $response->json(['message' => 'pong'])); (new TestClient($app)) ->get('/api/ping') ->assertSuccessful() ->assertJson(['message' => 'pong']); } }
Run it with pam test. The old Pam\Testing\TestClient and Pam\Testing\TestResponse names remain available as aliases.
What you can build
- Fast controller and middleware tests
- JSON, headers, status, and validation assertions
- Regression suites for routes without network flakiness
| Role | Testing toolkit |
| Execution path | PHPUnit-compatible in-memory HTTP harness |
| This repository owns | Application-level HTTP test ergonomics |
| Boundary | Transport, TLS, proxy, and kernel behavior still require integration tests |
API
| Surface | Methods |
|---|---|
TestClient |
request(), get($target, $headers), postJson($target, $payload, $headers) |
TestResponse |
assertStatus(), assertSuccessful(), assertHeader(), assertJson(), assertJsonPath(), header(), json() |
$client = new Pam\Http\Testing\TestClient($app); $client->get('/users/42') ->assertSuccessful() ->assertJsonPath('id', '42');
Docs
Part of the PAM ecosystem
PAM runs PHP natively on servers, desktops and phones. This repository is one piece of it.
| PAM | PAM Desktop | PAM Native | Ecosystem |
|---|---|---|---|
| the runtime and CLI | native desktop apps in PHP | native Android and iOS apps in PHP | every official package and plugin |
Docs: push-in.github.io/pam-docs · Issues
Apache License 2.0: use, modify and distribute for any purpose, including commercially · Made in Brazil by Pushin