Skip to content

Commit

Permalink
add phpunit extension
Browse files Browse the repository at this point in the history
  • Loading branch information
SjorsO committed Sep 6, 2019
1 parent 360993c commit 731cd4c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 34 deletions.
5 changes: 4 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand All @@ -22,6 +22,9 @@
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<extensions>
<extension class="Tests\Bootstrap"/>
</extensions>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
Expand Down
42 changes: 42 additions & 0 deletions tests/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -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'));
}
}
33 changes: 0 additions & 33 deletions tests/bootstrap.php

This file was deleted.

0 comments on commit 731cd4c

Please sign in to comment.