TestCase (Foundation\Testing)
TestCase
class TestCase extends PHPUnit_Framework_TestCase (View source)
Traits
InteractsWithContainer |
MakesHttpRequests |
ImpersonatesUsers |
InteractsWithAuthentication |
InteractsWithConsole |
InteractsWithDatabase |
InteractsWithSession |
MocksApplicationServices |
InteractsWithPages |
Methods
$this | visit(string $uri) Visit the given URI with a GET request. | from InteractsWithPages |
$this | visitRoute(string $route, array $parameters = array()) Visit the given named route with a GET request. | from InteractsWithPages |
$this | within(string $element, Closure $callback) Narrow the test content to a specific area of the page. | from InteractsWithPages |
$this | see(string $text, bool $negate = false) Assert that a given string is seen on the current HTML. | from InteractsWithPages |
$this | dontSee(string $text) Assert that a given string is not seen on the current HTML. | from InteractsWithPages |
$this | seeElement(string $selector, array $attributes = array(), bool $negate = false) Assert that an element is present on the page. | from InteractsWithPages |
$this | dontSeeElement(string $selector, array $attributes = array()) Assert that an element is not present on the page. | from InteractsWithPages |
$this | seeText(string $text, bool $negate = false) Assert that a given string is seen on the current text. | from InteractsWithPages |
$this | dontSeeText(string $text) Assert that a given string is not seen on the current text. | from InteractsWithPages |
$this | seeInElement(string $element, string $text, bool $negate = false) Assert that a given string is seen inside an element. | from InteractsWithPages |
$this | dontSeeInElement(string $element, string $text) Assert that a given string is not seen inside an element. | from InteractsWithPages |
$this | seeLink(string $text, string|null $url = null, bool $negate = false) Assert that a given link is seen on the page. | from InteractsWithPages |
$this | dontSeeLink(string $text, string|null $url = null) Assert that a given link is not seen on the page. | from InteractsWithPages |
$this | seeInField(string $selector, string $expected, bool $negate = false) Assert that an input field contains the given value. | from InteractsWithPages |
$this | dontSeeInField(string $selector, string $value) Assert that an input field does not contain the given value. | from InteractsWithPages |
$this | seeIsSelected(string $selector, string $value, bool $negate = false) Assert that the expected value is selected. | from InteractsWithPages |
$this | dontSeeIsSelected(string $selector, string $value) Assert that the given value is not selected. | from InteractsWithPages |
$this | seeIsChecked(string $selector, bool $negate = false) Assert that the given checkbox is selected. | from InteractsWithPages |
$this | dontSeeIsChecked(string $selector) Assert that the given checkbox is not selected. | from InteractsWithPages |
$this | withoutMiddleware() Disable middleware for the test. | from MakesHttpRequests |
$this | json(string $method, string $uri, array $data = array(), array $headers = array()) Visit the given URI with a JSON request. | from MakesHttpRequests |
$this | get(string $uri, array $headers = array()) Visit the given URI with a GET request. | from MakesHttpRequests |
$this | getJson(string $uri, array $headers = array()) Visit the given URI with a GET request, expecting a JSON response. | from MakesHttpRequests |
$this | post(string $uri, array $data = array(), array $headers = array()) Visit the given URI with a POST request. | from MakesHttpRequests |
$this | postJson(string $uri, array $data = array(), array $headers = array()) Visit the given URI with a POST request, expecting a JSON response. | from MakesHttpRequests |
$this | put(string $uri, array $data = array(), array $headers = array()) Visit the given URI with a PUT request. | from MakesHttpRequests |
$this | putJson(string $uri, array $data = array(), array $headers = array()) Visit the given URI with a PUT request, expecting a JSON response. | from MakesHttpRequests |
$this | patch(string $uri, array $data = array(), array $headers = array()) Visit the given URI with a PATCH request. | from MakesHttpRequests |
$this | patchJson(string $uri, array $data = array(), array $headers = array()) Visit the given URI with a PATCH request, expecting a JSON response. | from MakesHttpRequests |
$this | delete(string $uri, array $data = array(), array $headers = array()) Visit the given URI with a DELETE request. | from MakesHttpRequests |
$this | deleteJson(string $uri, array $data = array(), array $headers = array()) Visit the given URI with a DELETE request, expecting a JSON response. | from MakesHttpRequests |
$this | handle(Request $request) Send the given request through the application. | from MakesHttpRequests |
$this | seeJsonEquals(array $data) Assert that the response contains an exact JSON array. | from MakesHttpRequests |
$this | seeJson(array $data = null, bool $negate = false) Assert that the response contains JSON. | from MakesHttpRequests |
$this | dontSeeJson(array $data = null) Assert that the response doesn't contain JSON. | from MakesHttpRequests |
$this | seeJsonStructure(array $structure = null, array|null $responseData = null) Assert that the JSON response has a given structure. | from MakesHttpRequests |
Response | call(string $method, string $uri, array $parameters = array(), array $cookies = array(), array $files = array(), array $server = array(), string $content = null) Call the given URI and return the Response. | from MakesHttpRequests |
Response | callSecure(string $method, string $uri, array $parameters = array(), array $cookies = array(), array $files = array(), array $server = array(), string $content = null) Call the given HTTPS URI and return the Response. | from MakesHttpRequests |
Response | action(string $method, string $action, array $wildcards = array(), array $parameters = array(), array $cookies = array(), array $files = array(), array $server = array(), string $content = null) Call a controller action and return the Response. | from MakesHttpRequests |
Response | route(string $method, string $name, array $routeParameters = array(), array $parameters = array(), array $cookies = array(), array $files = array(), array $server = array(), string $content = null) Call a named route and return the Response. | from MakesHttpRequests |
$this | assertResponseOk() Assert that the client response has an OK status code. | from MakesHttpRequests |
$this | assertResponseStatus(int $code) Assert that the client response has a given code. | from MakesHttpRequests |
$this | assertViewHas(string|array $key, mixed $value = null) Assert that the response view has a given piece of bound data. | from MakesHttpRequests |
$this | assertViewHasAll(array $bindings) Assert that the view has a given list of bound data. | from MakesHttpRequests |
$this | assertViewMissing(string $key) Assert that the response view is missing a piece of bound data. | from MakesHttpRequests |
$this | assertRedirectedTo(string $uri, array $with = array()) Assert whether the client was redirected to a given URI. | from MakesHttpRequests |
$this | assertRedirectedToRoute(string $name, array $parameters = array(), array $with = array()) Assert whether the client was redirected to a given route. | from MakesHttpRequests |
$this | assertRedirectedToAction(string $name, array $parameters = array(), array $with = array()) Assert whether the client was redirected to a given action. | from MakesHttpRequests |
void | dump() Dump the content from the last response. | from MakesHttpRequests |
$this | actingAs(Authenticatable $user, string|null $driver = null) Set the currently logged in user for the application. | from ImpersonatesUsers |
$this | be(Authenticatable $user, string|null $driver = null) Set the currently logged in user for the application. | from ImpersonatesUsers |
$this | seeIsAuthenticated(string|null $guard = null) Assert that the user is authenticated. | from InteractsWithAuthentication |
$this | dontSeeIsAuthenticated(string|null $guard = null) Assert that the user is not authenticated. | from InteractsWithAuthentication |
$this | seeIsAuthenticatedAs($user, string|null $guard = null) Assert that the user is authenticated as the given user. | from InteractsWithAuthentication |
$this | seeCredentials(array $credentials, string|null $guard = null) Assert that the given credentials are valid. | from InteractsWithAuthentication |
$this | dontSeeCredentials(array $credentials, string|null $guard = null) Assert that the given credentials are invalid. | from InteractsWithAuthentication |
int | artisan(string $command, array $parameters = array()) Call artisan command and return code. | from InteractsWithConsole |
$this | seed(string $class = 'DatabaseSeeder') Seed a given database connection. | from InteractsWithDatabase |
$this | withSession(array $data) Set the session to the given array. | from InteractsWithSession |
$this | session(array $data) Set the session to the given array. | from InteractsWithSession |
$this | flushSession() Flush all of the current session data. | from InteractsWithSession |
$this | seeInSession(string|array $key, mixed $value = null) Assert that the session has a given value. | from InteractsWithSession |
$this | assertSessionHas(string|array $key, mixed $value = null) Assert that the session has a given value. | from InteractsWithSession |
$this | assertSessionHasAll(array $bindings) Assert that the session has a given list of values. | from InteractsWithSession |
$this | assertSessionMissing(string|array $key) Assert that the session does not have a given key. | from InteractsWithSession |
$this | assertSessionHasErrors(string|array $bindings = array(), mixed $format = null) Assert that the session has errors bound. | from InteractsWithSession |
$this | assertHasOldInput() Assert that the session has old input. | from InteractsWithSession |
$this | expectsEvents(array|string $events) Specify a list of events that should be fired for the given operation. | from MocksApplicationServices |
$this | doesntExpectEvents(array|string $events) Specify a list of events that should not be fired for the given operation. | from MocksApplicationServices |
$this | expectsModelEvents(string $model, array|string $events) Specify a list of events that should be fired for the given operation. | from MocksApplicationServices |
$this | doesntExpectModelEvents(string $model, array|string $events) Specify a list of events that should not be fired for the given operation. | from MocksApplicationServices |
$this | withoutObservers(array|string $observers) Specify a list of observers that will not run for the given operation. | from MocksApplicationServices |
HttpKernelInterface | createApplication() Creates the application. | |
void | afterApplicationCreated(callable $callback) Register a callback to be run after the application is created. |
Details
$this visit(string $uri)
Visit the given URI with a GET request.
$this visitRoute(string $route, array $parameters = array())
Visit the given named route with a GET request.
$this within(string $element, Closure $callback)
Narrow the test content to a specific area of the page.
$this see(string $text, bool $negate = false)
Assert that a given string is seen on the current HTML.
$this dontSee(string $text)
Assert that a given string is not seen on the current HTML.
$this seeElement(string $selector, array $attributes = array(), bool $negate = false)
Assert that an element is present on the page.
$this dontSeeElement(string $selector, array $attributes = array())
Assert that an element is not present on the page.
$this seeText(string $text, bool $negate = false)
Assert that a given string is seen on the current text.
$this dontSeeText(string $text)
Assert that a given string is not seen on the current text.
$this seeInElement(string $element, string $text, bool $negate = false)
Assert that a given string is seen inside an element.
$this dontSeeInElement(string $element, string $text)
Assert that a given string is not seen inside an element.
$this seeLink(string $text, string|null $url = null, bool $negate = false)
Assert that a given link is seen on the page.
$this dontSeeLink(string $text, string|null $url = null)
Assert that a given link is not seen on the page.
$this seeInField(string $selector, string $expected, bool $negate = false)
Assert that an input field contains the given value.
$this dontSeeInField(string $selector, string $value)
Assert that an input field does not contain the given value.
$this seeIsSelected(string $selector, string $value, bool $negate = false)
Assert that the expected value is selected.
$this dontSeeIsSelected(string $selector, string $value)
Assert that the given value is not selected.
$this seeIsChecked(string $selector, bool $negate = false)
Assert that the given checkbox is selected.
$this dontSeeIsChecked(string $selector)
Assert that the given checkbox is not selected.
$this withoutMiddleware()
Disable middleware for the test.
$this json(string $method, string $uri, array $data = array(), array $headers = array())
Visit the given URI with a JSON request.
$this get(string $uri, array $headers = array())
Visit the given URI with a GET request.
$this getJson(string $uri, array $headers = array())
Visit the given URI with a GET request, expecting a JSON response.
$this post(string $uri, array $data = array(), array $headers = array())
Visit the given URI with a POST request.
$this postJson(string $uri, array $data = array(), array $headers = array())
Visit the given URI with a POST request, expecting a JSON response.
$this put(string $uri, array $data = array(), array $headers = array())
Visit the given URI with a PUT request.
$this putJson(string $uri, array $data = array(), array $headers = array())
Visit the given URI with a PUT request, expecting a JSON response.
$this patch(string $uri, array $data = array(), array $headers = array())
Visit the given URI with a PATCH request.
$this patchJson(string $uri, array $data = array(), array $headers = array())
Visit the given URI with a PATCH request, expecting a JSON response.
$this delete(string $uri, array $data = array(), array $headers = array())
Visit the given URI with a DELETE request.
$this deleteJson(string $uri, array $data = array(), array $headers = array())
Visit the given URI with a DELETE request, expecting a JSON response.
$this handle(Request $request)
Send the given request through the application.
This method allows you to fully customize the entire Request object.
$this seeJsonEquals(array $data)
Assert that the response contains an exact JSON array.
$this seeJson(array $data = null, bool $negate = false)
Assert that the response contains JSON.
$this dontSeeJson(array $data = null)
Assert that the response doesn't contain JSON.
$this seeJsonStructure(array $structure = null, array|null $responseData = null)
Assert that the JSON response has a given structure.
Response call(string $method, string $uri, array $parameters = array(), array $cookies = array(), array $files = array(), array $server = array(), string $content = null)
Call the given URI and return the Response.
Response callSecure(string $method, string $uri, array $parameters = array(), array $cookies = array(), array $files = array(), array $server = array(), string $content = null)
Call the given HTTPS URI and return the Response.
Response action(string $method, string $action, array $wildcards = array(), array $parameters = array(), array $cookies = array(), array $files = array(), array $server = array(), string $content = null)
Call a controller action and return the Response.
Response route(string $method, string $name, array $routeParameters = array(), array $parameters = array(), array $cookies = array(), array $files = array(), array $server = array(), string $content = null)
Call a named route and return the Response.
$this assertResponseOk()
Assert that the client response has an OK status code.
$this assertResponseStatus(int $code)
Assert that the client response has a given code.
$this assertViewHas(string|array $key, mixed $value = null)
Assert that the response view has a given piece of bound data.
$this assertViewHasAll(array $bindings)
Assert that the view has a given list of bound data.
$this assertViewMissing(string $key)
Assert that the response view is missing a piece of bound data.
$this assertRedirectedTo(string $uri, array $with = array())
Assert whether the client was redirected to a given URI.
$this assertRedirectedToRoute(string $name, array $parameters = array(), array $with = array())
Assert whether the client was redirected to a given route.
$this assertRedirectedToAction(string $name, array $parameters = array(), array $with = array())
Assert whether the client was redirected to a given action.
void dump()
Dump the content from the last response.
$this actingAs(Authenticatable $user, string|null $driver = null)
Set the currently logged in user for the application.
$this be(Authenticatable $user, string|null $driver = null)
Set the currently logged in user for the application.
$this seeIsAuthenticated(string|null $guard = null)
Assert that the user is authenticated.
$this dontSeeIsAuthenticated(string|null $guard = null)
Assert that the user is not authenticated.
$this seeIsAuthenticatedAs($user, string|null $guard = null)
Assert that the user is authenticated as the given user.
$this seeCredentials(array $credentials, string|null $guard = null)
Assert that the given credentials are valid.
$this dontSeeCredentials(array $credentials, string|null $guard = null)
Assert that the given credentials are invalid.
int artisan(string $command, array $parameters = array())
Call artisan command and return code.
$this seed(string $class = 'DatabaseSeeder')
Seed a given database connection.
$this withSession(array $data)
Set the session to the given array.
$this session(array $data)
Set the session to the given array.
$this flushSession()
Flush all of the current session data.
$this seeInSession(string|array $key, mixed $value = null)
Assert that the session has a given value.
$this assertSessionHas(string|array $key, mixed $value = null)
Assert that the session has a given value.
$this assertSessionHasAll(array $bindings)
Assert that the session has a given list of values.
$this assertSessionMissing(string|array $key)
Assert that the session does not have a given key.
$this assertSessionHasErrors(string|array $bindings = array(), mixed $format = null)
Assert that the session has errors bound.
$this assertHasOldInput()
Assert that the session has old input.
$this expectsEvents(array|string $events)
Specify a list of events that should be fired for the given operation.
These events will be mocked, so that handlers will not actually be executed.
$this doesntExpectEvents(array|string $events)
Specify a list of events that should not be fired for the given operation.
These events will be mocked, so that handlers will not actually be executed.
$this expectsModelEvents(string $model, array|string $events)
Specify a list of events that should be fired for the given operation.
These events will be mocked, so that handlers will not actually be executed.
$this doesntExpectModelEvents(string $model, array|string $events)
Specify a list of events that should not be fired for the given operation.
These events will be mocked, so that handlers will not actually be executed.
$this withoutObservers(array|string $observers)
Specify a list of observers that will not run for the given operation.
abstract HttpKernelInterface createApplication()
Creates the application.
Needs to be implemented by subclasses.
void afterApplicationCreated(callable $callback)
Register a callback to be run after the application is created.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.3/Illuminate/Foundation/Testing/TestCase.html