sofa/laravel-kahlan
| Install | |
|---|---|
composer require sofa/laravel-kahlan |
|
| Latest Version: | v5.6 |
| PHP: | >=7.0 |
| Laravel: | 6 · 7 · 8 |
| Older releases: | 5 |
| License: | MIT |
| Last Updated: | Apr 6, 2021 |
| Links: | GitHub · Packagist |
Sofa/laravel-kahlan
Kahlan suite for testing Laravel application providing intuitive kahlan (jasmine based) describe-it syntax with Laravel functional testing goodies.
See usage example on https://github.com/jarektkaczyk/kahlan-driven-laravel
Why I should use the package & how it works?
Take a look at the example spec
First use in 3 steps
-
Add to your project
composer require --dev sofa/laravel-kahlan:"~5.4" -
Add this line to your kahlan config file (create it if necessary):
/* /path/to/your/app/kahlan-config.php */ <?php Sofa\LaravelKahlan\Env::bootstrap($this); -
Create your first spec in
/specfolder, for example/spec/AppSpec.phpand run test suite withvendor/bin/kahlan. Working example can be found on https://github.com/jarektkaczyk/kahlan-driven-laravel/* /path/to/your/app/spec/AppSpec.php */ <?php describe('My awesome Kahlan driven Laravel app', function () { it("provides the same testing API as Laravel's own TestCase", function () { $this->laravel->get('/') ->assertSee('Laravel 5') ->assertStatus(200); }); }
Optional stuff
-
Should you need to customize .env variables for the test suite, you have 2 options:
-
In the
.env.kahlanfile for persistent variables -
At runtime:
/path/to/app$ vendor/bin/kahlan -env=DB_CONNECTION=sqlite,MAIL_DRIVER=log
-
-
In your specs you can use all the kahlan features, as well as Laravel testing sugar:
- helpers:
app(),event()etc - Application methods
$this->app->method()or$this->laravel->method() - Laravel TestCase features, eg.
$this->laravel->get('/')->assertResponseOk() - Application instance as either of:
$this->app === $this->laravel->app === app()
- helpers:
-
For tests that don't require Laravel there's
--no-laravelcli option, since booting up the application for each test has huge impact on performance:/path/to/app$ vendor/bin/kahlan --spec=spec/unit --no-laravelAlternatively you can provide
NO_LARAVEL=truein.env/.env.kahlanfile, then you would enable laravel only when necessary:/path/to/app$ vendor/bin/kahlan --spec=spec/functional --no-laravel=false
#Happy coding!
Related Packages
Lumen fork of orchestra/testbench-core - Testing Helper for Lumen Development
Lumen fork of the orchestra/testbench Laravel Testing Helper for Packages Develo...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v5.6 | >=7.0 | >=6.20.14 | MIT | |
| v5.5 | >=7.0 | 5.5.* | MIT | |
| v5.4.3 | 5.4.* | MIT | ||
| v5.4.2 | 5.4.* | MIT | ||
| v5.4.1 | 5.4.* | MIT | ||
| v5.4 | 5.4.* | MIT | ||
| v5.3.2 | ^5.3 | MIT | ||
| v5.3.1 | 5.3.* | MIT | ||
| v5.3 | 5.3.* | MIT | ||
| v5.2.3 | 5.2.* | MIT | ||
| v5.2.2 | 5.2.* | MIT | ||
| v5.2.1 | 5.2.* | MIT | ||
| v5.2 | 5.2.* | MIT | ||
| v5.1.1 | 5.1.* | MIT | ||
| v5.1 | 5.1.* | MIT | ||
| v0.2 | 5.1.* | MIT | ||
| v0.1 | 5.1.*| | MIT |