Skip to content
Jeffrey Way edited this page Apr 16, 2015 · 6 revisions

If you wish to test your APIs, Integrated can assist you!

Please note that, temporarily, the following method calls are exclusive to the Laravel extension. This will change soon.

get($uri) or hit($uri)

Make a GET request to the given URI.

$this->get('/some-endpoint')
     ->seeJson();

post($uri, array $data)

Make a POST request to the given URI, and pass through any optional parameters.

$this->post('/some-endpoint', ['name' => 'joe']);

put($uri, array $data)

Make a PUT request to the given URI, and pass through the applicable data.

$this->put('/some-endpoint', ['name' => 'joe']);

patch($uri, array $data)

Make a PATCH request to the given URI, and pass through the applicable data.

$this->patch('/some-endpoint', ['name' => 'joe']);

delete($uri)

Make a DELETE request to the given URI.

$this->delete('/posts/1');

seeJson() or seeIsJson()

Assert that the last response is JSON (and not HTML, a string, etc.).

$this->get('/api/posts')
     ->seeJson();

seeStatusCode($code) or seeStatusCodeIs($code)

$this->get('/api/posts')
     ->seeStatusCode(200);

Ensure that the status code from the previous request matches what you provide.

seeJsonEquals($expected)

Assert that the returned JSON from the last response is equal to the provided JSON or array. If an array is provided, Integrated will json_encode it for you automatically to perform the comparison.

$this->get('/api/posts')
     ->seeJsonEquals(['title' => 'Foo', 'body' => 'Bar']);

seeJsonContains($expected)

$this->get('/api/posts')
     ->seeJsonContains(['title' => 'Foo']);

Assert that the returned JSON from the last response matches the provided array.

Clone this wiki locally