PHPackages                             jamesst20/kahlan-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. jamesst20/kahlan-laravel

ActiveLibrary[Testing &amp; Quality](/categories/testing)

jamesst20/kahlan-laravel
========================

Kahlan support for Laravel

1.0.0(7y ago)34742[4 issues](https://github.com/jamesst20/kahlan-laravel/issues)PHPPHP ^7.1.3

Since Mar 13Pushed 7y ago1 watchersCompare

[ Source](https://github.com/jamesst20/kahlan-laravel)[ Packagist](https://packagist.org/packages/jamesst20/kahlan-laravel)[ RSS](/packages/jamesst20-kahlan-laravel/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (2)Used By (0)

Jamesst20/kahlan-laravel
========================

[](#jamesst20kahlan-laravel)

[Kahlan](https://kahlan.github.io/docs) is a full-featured Unit &amp; BDD test framework a la RSpec/JSpec which uses a describe-it syntax and moves testing in PHP one step forward.

Why do I need this package
--------------------------

[](#why-do-i-need-this-package)

While it's true that you can use the vanilla Kahlan library, you cannot access to any of the Laravel TestCase helpers method.

Compatibility
-------------

[](#compatibility)

Only **Laravel 5.8** is currently supported because this library relies on phpdotenv v3.0 shipped with Laravel. It also only supports the latest **Kahlan** version (v4.6 as of now) because it is depedent on the new `afterEach` behavior deployed on [v4.6](https://github.com/kahlan/kahlan/commit/439415be3fd2b950227c4e46b582bf853b3d5718).

Installation
------------

[](#installation)

```
composer require --dev jamesst20/kahlan-laravel:^1.0

```

Usage
-----

[](#usage)

Getting the application instance : `$this->app`, `$this->laravel->app`, `app()` are all equivalent ways and will return the same instance.

In a vanilla Laravel TestCase, we can access helpers by doing `$this->insertHelperMethod` such as `$this->assertDatabaseHas('users', ['email' => 'test@email.com']);`

In a kahlan environment, it is as simple as prefixing the method with `$this->laravel->insertHelperMethod`.

Please note that `$this->laravel`and `$this->app` is not accessible in `beforeAll`, `afterAll` callback but is as soon as in `beforeEach`.

Example
-------

[](#example)

Vanilla Laravel TestCase (PHPUnit)

```
