384 Laravel 6 changes (#385)
* 384 Laravel 6 changes * Library versions * Update package versions * Add keyType to models * Remove unused dependencies * StyleCI fixes * Fix models for test * Fix tests output and update test runner * Unused imports * Update exceptions handler * Fix login page
This commit is contained in:
39
tests/Bootstrap.php
Normal file
39
tests/Bootstrap.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use PHPUnit\Runner\AfterLastTestHook;
|
||||
use PHPUnit\Runner\BeforeFirstTestHook;
|
||||
|
||||
class Bootstrap implements BeforeFirstTestHook, AfterLastTestHook
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bootstrap The Test Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may specify console commands that execute once before your test is
|
||||
| run. You are free to add your own additional commands or logic into
|
||||
| this file as needed in order to help your test suite run quicker.
|
||||
|
|
||||
*/
|
||||
use CreatesApplication;
|
||||
|
||||
public function executeBeforeFirstTest(): void
|
||||
{
|
||||
$console = $this->createApplication()->make(Kernel::class);
|
||||
$commands = [
|
||||
'config:cache',
|
||||
'event:cache',
|
||||
];
|
||||
foreach ($commands as $command) {
|
||||
$console->call($command);
|
||||
}
|
||||
}
|
||||
|
||||
public function executeAfterLastTest(): void
|
||||
{
|
||||
array_map('unlink', glob('bootstrap/cache/*.phpunit.php'));
|
||||
}
|
||||
}
|
||||
21
tests/CreatesApplication.php
Normal file
21
tests/CreatesApplication.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
|
||||
trait CreatesApplication
|
||||
{
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
}
|
||||
@@ -7,14 +7,15 @@ use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Tests\CreatesApplication;
|
||||
use Tests\TestData;
|
||||
|
||||
/**
|
||||
* Class TestCase
|
||||
*/
|
||||
class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
{
|
||||
use TestData;
|
||||
use CreatesApplication;
|
||||
|
||||
/**
|
||||
* The base URL to use while testing the application.
|
||||
@@ -45,8 +46,10 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
ThrottleRequests::class
|
||||
);
|
||||
|
||||
Mail::fake();
|
||||
|
||||
Artisan::call('database:create', ['--reset' => true]);
|
||||
Artisan::call('migrate:refresh', ['--env' => 'unittest']);
|
||||
Artisan::call('migrate:refresh', ['--env' => 'testing']);
|
||||
}
|
||||
|
||||
public function tearDown() : void
|
||||
@@ -54,18 +57,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the application. Required to be implemented
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
return $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user
|
||||
* @param array $headers
|
||||
|
||||
Reference in New Issue
Block a user