PHP code example of midnightsuyama / laravel-kahlan4

1. Go to this page and download the library: Download midnightsuyama/laravel-kahlan4 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

midnightsuyama / laravel-kahlan4 example snippets




LaravelKahlan4\Config::bootstrap($this);


// spec/User.spec.php

describe('User', function() {
    it('has a name "example"', function() {
        $user = factory(App\User::class)->make(['name' => 'xample']);
        expect($user['name'])->toEqual('example');
    });
});

$response = $this->laravel->get('/');

use Illuminate\Foundation\Testing\RefreshDatabase;

describe('User table', function() {
    beforeAll(function() {
        $this->laravel->useTrait(RefreshDatabase::class);
    });

    it('has no records', function() {
        $count = App\User::count();
        expect($count)->toEqual(0);
    });
});

describe('Response', function() {
    it('has a 200 status code', function() {
        $response = $this->laravel->get('/');
        expect($response)->toPassStatus(200);
    });
});

describe('User', function() {
    it('is authenticated', function() {
        $user = factory(App\User::class)->make();
        $this->laravel->actingAs($user);
        expect($this->laravel)->toPassAuthenticated();
    });
});

describe('User table', function() {
    it('has records', function() {
        $user = factory(App\User::class)->create();
        expect($this->laravel)->toPassDatabaseHas('users', ['email' => $user['email']]);
    });
});

use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Support\Facades\Notification;

describe('User', function() {
    it('is notified', function() {
        $notification = Notification::fake();
        expect($notification)->toPassNothingSent();

        $user = factory(App\User::class)->create();
        $user->notify(new VerifyEmail);
        expect($notification)->toPassSentTo($user, VerifyEmail::class);
    });
});