goez / behat-laravel-extension
Enhance Laracasts Behat Laravel Extension
Installs: 4 948
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 0
Forks: 2
Open Issues: 2
Requires
- behat/mink-extension: ^2.0
- illuminate/contracts: ~5.1
- laracasts/behat-laravel-extension: ~1.0
- mockery/mockery: ^0.9.4
- phpunit/phpunit: ~4.7
- symfony/http-kernel: ~2.6
Requires (Dev)
- phpspec/phpspec: ~2.1
This package is auto-updated.
Last update: 2018-10-31 08:36:47 UTC
README
I like to develop a Laravel application by Behat way. With Laracasts' Behat Laravel Extension, it made my dreams come true.
After I upgraded to Laravel 5.1, I fall in love the testing methods such as seeInDatabase
or be
in the new testing framework, but I can not use them in Behat context class.
So I combined the Behat-Laravel-Extension and Laravel testing framework, and made this extension.
What does the extension do?
This extension provides two features:
- You can use the testing APIs of Laravel Testing in your Behat context class. For example:
/** * @Given a user whose name is :name * @param $name */ public function aUserWhoseNameIs($name) { $this->user = factory(App\User::class)->create([ 'name' => $name, ]); $this->seeInDatabase('users', [ 'name' => $this->user->name, ]); } /** * @When user attempts to sign in */ public function userAttemptsToSignIn() { $this->be($this->user); }
The seeInDatabase
, be
and other testing methods are provided by Illuminate\Foundation\Testing\ApplicationTrait
and only can be used in PHPUnit test case, but you can use them in Behat context class now.
- You can use the
assert*
methods these provided byPHPUnit_Framework_Assert
directly. For example:
/** * @Then user should be sign in */ public function userShouldBeSignIn() { $this->assertTrue(Auth::check()); }
This extension is still in development. If you have any issues, please let me know.
Installation
- Install this extension by composer:
composer require goez/behat-laravel-extension
- Add this extension and mink extension in your
behat.yml
:
default: extensions: Goez\BehatLaravelExtension: Behat\MinkExtension: default_session: laravel laravel: ~
- Let your context class extends the
Goez\BehatLaravelExtension\Context\LaravelContext
class:
use Goez\BehatLaravelExtension\Context\LaravelContext; class FeatureContext extends LaravelContext { // ... }
License
MIT