Download the PHP package midnightsuyama/laravel-kahlan4 without Composer
On this page you can find all versions of the php package midnightsuyama/laravel-kahlan4. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download midnightsuyama/laravel-kahlan4
More information about midnightsuyama/laravel-kahlan4
Files in midnightsuyama/laravel-kahlan4
Package laravel-kahlan4
Short Description Kahlan specs suite for Laravel
License MIT
Homepage https://github.com/midnightSuyama/laravel-kahlan4
Informations about the package laravel-kahlan4
laravel-kahlan4
Kahlan specs suite for Laravel
Features
- Support Laravel test methods
- Support Laravel test traits
- Support Laravel test assertions
Installation
$ composer require --dev midnightsuyama/laravel-kahlan4
Usage
Add this line to your kahlan-config.php file (create it if necessary):
and
$ ./vendor/bin/kahlan
Example
Method
$this->laravel is an instance of Illuminate\Foundation\Testing\TestCase subclass. It can call test methods of Illuminate\Foundation\Testing\Concerns.
Trait
Call $this->laravel->useTrait() in beforeAll, if you want to use test traits. That trait is set before beforeEach is called.
Support traits
- Illuminate\Foundation\Testing\RefreshDatabase
- Illuminate\Foundation\Testing\DatabaseMigrations
- Illuminate\Foundation\Testing\DatabaseTransactions
- Illuminate\Foundation\Testing\WithoutMiddleware
- Illuminate\Foundation\Testing\WithoutEvents
- Illuminate\Foundation\Testing\WithFaker
Matcher
Provied custom matchers. toPass* matcher is paired with assert* assertion by Laravel.
Response
| Matcher | Description |
|---|---|
| toPassSuccessful() | The response has a successful status code. |
| toPassOk() | The response has a 200 status code. |
| toPassNotFound() | The response has a not found status code. |
| toPassForbidden() | The response has a forbidden status code. |
| toPassUnauthorized() | The response has an unauthorized status code. |
| toPassCreated() | The response has a 201 status code. |
| toPassNoContent($status = 204) | The response has the given status code and no content. |
| toPassStatus($status) | The response has the given status code. |
| toPassRedirect($uri = null) | The response is redirecting to a given URI. |
| toPassHeader($headerName, $value = null) | The response contains the given header and equals the optional value. |
| toPassHeaderMissing($headerName) | The response does not contains the given header. |
| toPassLocation($uri) | The current location header matches the given URI. |
| toPassPlainCookie($cookieName, $value = null) | The response contains the given cookie and equals the optional value. |
| toPassCookie($cookieName, $value = null, $encrypted = true, $unserialize = false) | The response contains the given cookie and equals the optional value. |
| toPassCookieExpired($cookieName) | The response contains the given cookie and is expired. |
| toPassCookieNotExpired($cookieName) | The response contains the given cookie and is not expired. |
| toPassCookieMissing($cookieName) | The response does not contains the given cookie. |
| toPassSee($value) | The given string is contained within the response. |
| toPassSeeInOrder(array $values) | The given strings are contained in order within the response. |
| toPassSeeText($value) | The given string is contained within the response text. |
| toPassSeeTextInOrder(array $values) | The given strings are contained in order within the response text. |
| toPassDontSee($value) | The given string is not contained within the response. |
| toPassDontSeeText($value) | The given string is not contained within the response text. |
| toPassJson(array $data, $strict = false) | The response is a superset of the given JSON. |
| toPassExactJson(array $data) | The response has the exact given JSON. |
| toPassJsonFragment(array $data) | The response contains the given JSON fragment. |
| toPassJsonMissing(array $data, $exact = false) | The response does not contain the given JSON fragment. |
| toPassJsonMissingExact(array $data) | The response does not contain the exact JSON fragment. |
| toPassJsonPath($path, $expect, $strict = false) | The expected value exists at the given path in the response. |
| toPassJsonStructure(array $structure = null, $responseData = null) | The response has a given JSON structure. |
| toPassJsonCount(int $count, $key = null) | The response JSON has the expected count of items at the given key. |
| toPassJsonValidationErrors($errors) | The response has the given JSON validation errors. |
| toPassJsonMissingValidationErrors($keys = null) | The response has no JSON validation errors for the given keys. |
| toPassViewIs($value) | The response view equals the given value. |
| toPassViewHas($key, $value = null) | The response view has a given piece of bound data. |
| toPassViewHasAll(array $bindings) | The response view has a given list of bound data. |
| toPassViewMissing($key) | The response view is missing a piece of bound data. |
| toPassSessionHas($key, $value = null) | The session has a given value. |
| toPassSessionHasAll(array $bindings) | The session has a given list of values. |
| toPassSessionHasInput($key, $value = null) | The session has a given value in the flashed input array. |
| toPassSessionHasErrors($keys = [], $format = null, $errorBag = 'default') | The session has the given errors. |
| toPassSessionDoesntHaveErrors($keys = [], $format = null, $errorBag = 'default') | The session is missing the given errors. |
| toPassSessionHasNoErrors() | The session has no errors. |
| toPassSessionHasErrorsIn($errorBag, $keys = [], $format = null) | The session has the given errors. |
| toPassSessionMissing($key) | The session does not have a given key. |
Authentication
| Matcher | Description |
|---|---|
| toPassAuthenticated($guard = null) | The user is authenticated. |
| toPassGuest($guard = null) | The user is not authenticated. |
| toPassAuthenticatedAs($user, $guard = null) | The user is authenticated as the given user. |
| toPassCredentials(array $credentials, $guard = null) | The given credentials are valid. |
| toPassInvalidCredentials(array $credentials, $guard = null) | The given credentials are invalid. |
Database
| Matcher | Description |
|---|---|
| toPassDatabaseHas($table, array $data, $connection = null) | A given where condition exists in the database. |
| toPassDatabaseMissing($table, array $data, $connection = null) | A given where condition does not exist in the database. |
| toPassSoftDeleted($table, array $data = [], $connection = null) | The given record has been deleted. |
Notification
| Matcher | Description |
|---|---|
| toPassNothingSent() | No notifications were sent. |
| toPassSentTo($notifiable, $notification, $callback = null) | The given notification was sent based on a truth-test callback. |
| toPassNotSentTo($notifiable, $notification, $callback = null) | The given notification was not sent based on a truth-test callback. |
| toPassSentToTimes($notifiable, $notification, $times = 1) | The given notification was sent a number of times. |
| toPassTimesSent($expectedCount, $notification) | The total amount of times a notification was sent. |
Test
License
Licensed using the MIT license.
Acknowledgments
Inspired by sofa/laravel-kahlan.
All versions of laravel-kahlan4 with dependencies
laravel/framework Version ^6.0 || ^7.0 || ^8.0 || ^9.0
kahlan/kahlan Version ^4.6 || ^5.0