GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - smartexpose/laravel-kahlan: Laravel context for kahlan specs/tests - allows nice BDD way of developing Laravel app. https://softonsofa.com

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

31 Commits
31 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 

Repository files navigation

Sofa/laravel-kahlan

Kahlan suite for testing Laravel application providing intuitive kahlan (jasmine based) describe-it syntax with Laravel functional testing goodies.

If I'm saving you some time with my work, you can back me up on Patreon page.

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

  1. Add to your project

    composer require --dev sofa/laravel-kahlan:"~5.4"
    
  2. 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);
  3. Create your first spec in /spec folder, for example /spec/AppSpec.php and run test suite with vendor/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.kahlan file 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()
  • For tests that don't require Laravel there's --no-laravel cli option, since booting up the application for each test has huge impact on performance:

    /path/to/app$ vendor/bin/kahlan --spec=spec/unit --no-laravel
    

    Alternatively you can provide NO_LARAVEL=true in .env/.env.kahlan file, then you would enable laravel only when necessary:

    /path/to/app$ vendor/bin/kahlan --spec=spec/functional --no-laravel=false
    

#Happy coding!

About

Laravel context for kahlan specs/tests - allows nice BDD way of developing Laravel app. https://softonsofa.com

Resources

Readme
Activity
Custom properties

Stars

0 stars

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.