TestCase
class TestCase extends TestCase (View source)
Properties
| protected ?string | $url | The base url. If null, resolves to APP_URL env var, then to
http://127.0.0.1:8080 (the default of |
Methods
Replace the header map applied to every request.
Add (or override) a single header.
PATCH request (real HTTP PATCH — no _method POST hack).
DELETE request (real HTTP DELETE — no _method POST hack).
Dispatch a request by HTTP verb name.
Build a fresh HttpClient pre-configured with the current headers and pending attachments. Attachments are consumed (reset) after this call; headers persist for the lifetime of the test instance.
Resolve the base URL. Override this in a subclass for more elaborate setups (per-test base URLs, computed from env, etc.).
Details
TestCase
attach(array $attach)
Add files / multipart attachments to the next request.
Cleared automatically after the request is sent.
TestCase
withHeaders(array $headers)
Replace the header map applied to every request.
TestCase
withHeader(string $key, string $value)
Add (or override) a single header.
Response
get(string $url, array $param = [])
GET request.
Response
post(string $url, array $param = [])
POST request.
Response
put(string $url, array $param = [])
PUT request.
Response
patch(string $url, array $param = [])
PATCH request (real HTTP PATCH — no _method POST hack).
Response
delete(string $url, array $param = [])
DELETE request (real HTTP DELETE — no _method POST hack).
Response
head(string $url, array $param = [])
HEAD request (headers only, no body).
Response
options(string $url)
OPTIONS request (typically for CORS preflight).
Response
visit(string $method, string $url, array $params = [])
Dispatch a request by HTTP verb name.
protected HttpClient
newHttpClient()
Build a fresh HttpClient pre-configured with the current headers and pending attachments. Attachments are consumed (reset) after this call; headers persist for the lifetime of the test instance.
protected string
getBaseUrl()
Resolve the base URL. Override this in a subclass for more elaborate setups (per-test base URLs, computed from env, etc.).