PHP Class Flugg\Responder\Tests\Unit\ErrorResponseBuilderTest

Author: Alexander Tømmerås ([email protected])
Inheritance: extends Flugg\Responder\Tests\TestCase
Datei anzeigen Open project: flugger/laravel-responder

Public Methods

Method Description
respondMethodShouldAllowSettingHeaders ( ) Test that you can set any headers to the JSON response by passing a second argument to the [respond] method.
respondMethodShouldAllowSettingStatusCode ( ) Test that the [respond] method allows passing a status code as the first parameter.
respondMethodShouldReturnAJsonResponse ( ) Test that the [respond] method converts the error response into an instance of [\Illuminate\Http\JsonResponse] with a default status code of 500.
setErrorMethodShouldAddErrorData ( ) Test that error data is added when an error code is set using the [setError] method.
setErrorMethodShouldAllowAddingParametersToMessage ( ) Test that the [setError] method should allow passing any parameters to the translator when resolving the error message.
setErrorMethodShouldAllowOverridingErrorMessage ( ) Test that the [setError] method allows passing a string as second argument instead of an array of parameters, which will override the error message and set it explicitly.
setErrorMethodShouldResolveErrorMessageFromTranslator ( ) Test that the [setError] method attempts to resolve an error message from the translator.
setStatusMethodShouldFailIfStatusCodeIsInvalid ( ) Test that the [setStatus] method throws an [\InvalidArgumentException] when the status code given is not a valid error HTTP status code.
setStatusMethodShouldReturnItself ( ) Test that the [setStatus] method returns the response builder, allowing for fluent method chaining.
setStatusMethodShouldSetStatusCode ( ) Test that the [setStatus] method sets the HTTP status code on the response, providing an alternative, more explicit way of setting the status code.
toArrayMethodShouldSerializeData ( ) Test that the [toArray] method serializes the data given, using the default serializer and no data.
toCollectionMethodShouldReturnACollection ( ) Test that the [toCollection] serializes the data into a collection.
toJsonMethodShouldReturnJson ( ) Test that the [toJson] serializes the data into a JSON string.
youCanResolveASuccessResponseBuilderFromTheContainer ( ) Test that you can resolve an instance of [\Flugg\Responder\ErrorResponseBuilder] from the service container.

Method Details

respondMethodShouldAllowSettingHeaders() public method

Test that you can set any headers to the JSON response by passing a second argument to the [respond] method.

respondMethodShouldAllowSettingStatusCode() public method

Test that the [respond] method allows passing a status code as the first parameter.

respondMethodShouldReturnAJsonResponse() public method

Test that the [respond] method converts the error response into an instance of [\Illuminate\Http\JsonResponse] with a default status code of 500.

setErrorMethodShouldAddErrorData() public method

Test that error data is added when an error code is set using the [setError] method.

setErrorMethodShouldAllowAddingParametersToMessage() public method

Test that the [setError] method should allow passing any parameters to the translator when resolving the error message.

setErrorMethodShouldAllowOverridingErrorMessage() public method

Test that the [setError] method allows passing a string as second argument instead of an array of parameters, which will override the error message and set it explicitly.

setErrorMethodShouldResolveErrorMessageFromTranslator() public method

Test that the [setError] method attempts to resolve an error message from the translator.

setStatusMethodShouldFailIfStatusCodeIsInvalid() public method

Test that the [setStatus] method throws an [\InvalidArgumentException] when the status code given is not a valid error HTTP status code.

setStatusMethodShouldReturnItself() public method

Test that the [setStatus] method returns the response builder, allowing for fluent method chaining.

setStatusMethodShouldSetStatusCode() public method

Test that the [setStatus] method sets the HTTP status code on the response, providing an alternative, more explicit way of setting the status code.

toArrayMethodShouldSerializeData() public method

Test that the [toArray] method serializes the data given, using the default serializer and no data.

toCollectionMethodShouldReturnACollection() public method

Test that the [toCollection] serializes the data into a collection.

toJsonMethodShouldReturnJson() public method

Test that the [toJson] serializes the data into a JSON string.

youCanResolveASuccessResponseBuilderFromTheContainer() public method

Test that you can resolve an instance of [\Flugg\Responder\ErrorResponseBuilder] from the service container.