Code Monkey home page Code Monkey logo

auth-tests's Introduction

Missing tests for Laravel's auth module

Latest Stable Version License MIT PRs Welcome

Versioning

The version of this package reflects current major version of the Laravel framework. For example: If Laravel framework has version 5.6, version of this package compatible will be 5.6.*.

Installation

composer require dczajkowski/auth-tests --dev
php artisan make:auth # if not ran previously
php artisan make:auth-tests --without-email-verification

Edit phpunit.xml file by adding these two lines between <php> tags:

<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>

Alternatively, use different database than sqlite, but also different from the one used for development.

Using the e-mail verification feature

If you want to use the e-mail verification feature, you will have to make following changes:

  • update routes/web.php:
- Auth::routes();
+ Auth::routes(['verify' => true]);
  • update app/User.php:
- class User extends Authenticatable
+ class User extends Authenticatable implements MustVerifyEmail

Options

There are four flags for customizing your tests. You can use any combination of them. (All flags have their short version e.g. --zonda or -z)

# make:auth-tests
public function testUserCanLogout()
{
    //
}

# make:auth-tests --snake-case
public function test_user_can_logout()
{
    //
}

# make:auth-tests --annotation
/** @test */
public function userCanLogout()
{
    //
}

# make:auth-tests --public
function testUserCanLogout()
{
    //
}

# make:auth-tests --curly
public function testUserCanLogout() {
    //
}

# make:auth-tests -caps # or --zonda
/** @test */
function user_can_logout() {
    //
}

Since version 5.7 there has been a new test for email verification added. You can omit it by running --without-email-verification.

To review all flags run php artisan make:auth-tests --help.

Updating

To update tests when a new version of this package arrives:

composer update dczajkowski/auth-tests
php artisan make:auth-tests

Warning! All changes to the files this package provides will be lost when running this command!

Automate your workflow

Instead of including this package manually every project you create, simply create a bash function that will do that for you. I have included my personal function here. Feel free to edit it and reuse however you like.

Contributing

Feel free to make PRs to this repo.

License

License can be found in the LICENSE file. It is a simple MIT, which basically means -- use it however you like.

auth-tests's People

Contributors

dczajkowski avatar

Stargazers

Flávio H. Ferreira avatar

Watchers

Flávio H. Ferreira avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.