add phpunit extension
This commit is contained in:
parent
360993c11e
commit
731cd4c499
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit backupGlobals="false"
|
<phpunit backupGlobals="false"
|
||||||
backupStaticAttributes="false"
|
backupStaticAttributes="false"
|
||||||
bootstrap="tests/bootstrap.php"
|
bootstrap="vendor/autoload.php"
|
||||||
colors="true"
|
colors="true"
|
||||||
convertErrorsToExceptions="true"
|
convertErrorsToExceptions="true"
|
||||||
convertNoticesToExceptions="true"
|
convertNoticesToExceptions="true"
|
||||||
|
@ -22,6 +22,9 @@
|
||||||
<directory suffix=".php">./app</directory>
|
<directory suffix=".php">./app</directory>
|
||||||
</whitelist>
|
</whitelist>
|
||||||
</filter>
|
</filter>
|
||||||
|
<extensions>
|
||||||
|
<extension class="Tests\Bootstrap"/>
|
||||||
|
</extensions>
|
||||||
<php>
|
<php>
|
||||||
<server name="APP_ENV" value="testing"/>
|
<server name="APP_ENV" value="testing"/>
|
||||||
<server name="BCRYPT_ROUNDS" value="4"/>
|
<server name="BCRYPT_ROUNDS" value="4"/>
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?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'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,33 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Contracts\Console\Kernel;
|
|
||||||
|
|
||||||
require_once __DIR__.'/../vendor/autoload.php';
|
|
||||||
|
|
||||||
if (file_exists($_SERVER['APP_CONFIG_CACHE'])) {
|
|
||||||
unlink($_SERVER['APP_CONFIG_CACHE']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| 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.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
$commands = [
|
|
||||||
'config:cache',
|
|
||||||
'event:cache',
|
|
||||||
];
|
|
||||||
|
|
||||||
$app = require __DIR__.'/../bootstrap/app.php';
|
|
||||||
|
|
||||||
$console = tap($app->make(Kernel::class))->bootstrap();
|
|
||||||
|
|
||||||
foreach ($commands as $command) {
|
|
||||||
$console->call($command);
|
|
||||||
}
|
|
Loading…
Reference in New Issue