TestCase

class TestCase extends PHPUnit_Framework_TestCase (View source)

Traits

ApplicationTrait
AssertionsTrait

Properties

protected Application $app The Illuminate application instance. from ApplicationTrait
protected Client $client The HttpKernel client instance. from ApplicationTrait

Methods

void refreshApplication()

Refresh the application instance.

from ApplicationTrait
Response call(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true)

Call the given URI and return the Response.

from ApplicationTrait
Response callSecure(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true)

Call the given HTTPS URI and return the Response.

from ApplicationTrait
Response action(string $method, string $action, array $wildcards = array(), array $parameters = array(), array $files = array(), array $server = array(), string $content = null, bool $changeHistory = true)

Call a controller action and return the Response.

from ApplicationTrait
Response route(string $method, string $name, array $routeParameters = array(), array $parameters = array(), array $files = array(), array $server = array(), string $content = null, bool $changeHistory = true)

Call a named route and return the Response.

from ApplicationTrait
void session(array $data)

Set the session to the given array.

from ApplicationTrait
void flushSession()

Flush all of the current session data.

from ApplicationTrait
void startSession()

Start the session for the application.

from ApplicationTrait
void be(UserInterface $user, string $driver = null)

Set the currently logged in user for the application.

from ApplicationTrait
void seed(string $class = 'DatabaseSeeder')

Seed a given database connection.

from ApplicationTrait
Client createClient(array $server = array())

Create a new HttpKernel client instance.

from ApplicationTrait
void assertResponseOk()

Assert that the client response has an OK status code.

from AssertionsTrait
void assertResponseStatus(int $code)

Assert that the client response has a given code.

from AssertionsTrait
void assertViewHas(string|array $key, mixed $value = null)

Assert that the response view has a given piece of bound data.

from AssertionsTrait
void assertViewHasAll(array $bindings)

Assert that the view has a given list of bound data.

from AssertionsTrait
void assertViewMissing(string $key)

Assert that the response view is missing a piece of bound data.

from AssertionsTrait
void assertRedirectedTo(string $uri, array $with = array())

Assert whether the client was redirected to a given URI.

from AssertionsTrait
void assertRedirectedToRoute(string $name, array $parameters = array(), array $with = array())

Assert whether the client was redirected to a given route.

from AssertionsTrait
void assertRedirectedToAction(string $name, array $parameters = array(), array $with = array())

Assert whether the client was redirected to a given action.

from AssertionsTrait
void assertSessionHas(string|array $key, mixed $value = null)

Assert that the session has a given list of values.

from AssertionsTrait
void assertSessionHasAll(array $bindings)

Assert that the session has a given list of values.

from AssertionsTrait
void assertSessionHasErrors(string|array $bindings = array(), mixed $format = null)

Assert that the session has errors bound.

from AssertionsTrait
void assertHasOldInput()

Assert that the session has old input.

from AssertionsTrait
void setUp()

Setup the test environment.

HttpKernelInterface createApplication()

Creates the application.

Details

protected void refreshApplication()

Refresh the application instance.

Return Value

void

Response call(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true)

Call the given URI and return the Response.

Parameters

string $method
string $uri
array $parameters
array $files
array $server
string $content
bool $changeHistory

Return Value

Response

Response callSecure(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true)

Call the given HTTPS URI and return the Response.

Parameters

string $method
string $uri
array $parameters
array $files
array $server
string $content
bool $changeHistory

Return Value

Response

Response action(string $method, string $action, array $wildcards = array(), array $parameters = array(), array $files = array(), array $server = array(), string $content = null, bool $changeHistory = true)

Call a controller action and return the Response.

Parameters

string $method
string $action
array $wildcards
array $parameters
array $files
array $server
string $content
bool $changeHistory

Return Value

Response

Response route(string $method, string $name, array $routeParameters = array(), array $parameters = array(), array $files = array(), array $server = array(), string $content = null, bool $changeHistory = true)

Call a named route and return the Response.

Parameters

string $method
string $name
array $routeParameters
array $parameters
array $files
array $server
string $content
bool $changeHistory

Return Value

Response

void session(array $data)

Set the session to the given array.

Parameters

array $data

Return Value

void

void flushSession()

Flush all of the current session data.

Return Value

void

protected void startSession()

Start the session for the application.

Return Value

void

void be(UserInterface $user, string $driver = null)

Set the currently logged in user for the application.

Parameters

UserInterface $user
string $driver

Return Value

void

void seed(string $class = 'DatabaseSeeder')

Seed a given database connection.

Parameters

string $class

Return Value

void

protected Client createClient(array $server = array())

Create a new HttpKernel client instance.

Parameters

array $server

Return Value

Client

void assertResponseOk()

Assert that the client response has an OK status code.

Return Value

void

void assertResponseStatus(int $code)

Assert that the client response has a given code.

Parameters

int $code

Return Value

void

void assertViewHas(string|array $key, mixed $value = null)

Assert that the response view has a given piece of bound data.

Parameters

string|array $key
mixed $value

Return Value

void

void assertViewHasAll(array $bindings)

Assert that the view has a given list of bound data.

Parameters

array $bindings

Return Value

void

void assertViewMissing(string $key)

Assert that the response view is missing a piece of bound data.

Parameters

string $key

Return Value

void

void assertRedirectedTo(string $uri, array $with = array())

Assert whether the client was redirected to a given URI.

Parameters

string $uri
array $with

Return Value

void

void assertRedirectedToRoute(string $name, array $parameters = array(), array $with = array())

Assert whether the client was redirected to a given route.

Parameters

string $name
array $parameters
array $with

Return Value

void

void assertRedirectedToAction(string $name, array $parameters = array(), array $with = array())

Assert whether the client was redirected to a given action.

Parameters

string $name
array $parameters
array $with

Return Value

void

void assertSessionHas(string|array $key, mixed $value = null)

Assert that the session has a given list of values.

Parameters

string|array $key
mixed $value

Return Value

void

void assertSessionHasAll(array $bindings)

Assert that the session has a given list of values.

Parameters

array $bindings

Return Value

void

void assertSessionHasErrors(string|array $bindings = array(), mixed $format = null)

Assert that the session has errors bound.

Parameters

string|array $bindings
mixed $format

Return Value

void

void assertHasOldInput()

Assert that the session has old input.

Return Value

void

void setUp()

Setup the test environment.

Return Value

void

abstract HttpKernelInterface createApplication()

Creates the application.

Needs to be implemented by subclasses.

Return Value

HttpKernelInterface

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/4.2/Illuminate/Foundation/Testing/TestCase.html