1. Go to this page and download the library: Download jamesst20/kahlan-laravel 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/ */
jamesst20 / kahlan-laravel example snippets
namespace Tests\Feature;
use App\User;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ExampleTest extends TestCase
{
use RefreshDatabase;
public function testBasicTest()
{
$response = $this->get('/');
$response->assertStatus(200);
}
public function testUserCreation() {
factory(User::class)->create(['email' => '[email protected]']);
$this->laravel->assertDatabaseHas('users', ['email' => '[email protected]']);
}
}
use App\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
describe("Homepage", function() {
it("loads successfully", function() {
$response = $this->laravel->get('/');
expect($response->getStatusCode())->toEqual(200);
});
});
describe("User", function() {
beforeAll(function() {
$this->enabledTraits = array(RefreshDatabase::class);
});
it("should save user to database", function() {
factory(User::class)->create(['email' => '[email protected]']);
// There are cleaner way than using assertDatabaseHas though.
expect(function() {
$this->laravel->assertDatabaseHas('users', ['email' => '[email protected]']);
})->not->toThrow();
});
});