Created
June 23, 2017 06:02
-
-
Save grohiro/29be6a8e3b2be7bb92a000606a376fb4 to your computer and use it in GitHub Desktop.
An autoload.php for PHPUnit with Laravel 5+.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Put me into tests/autoload.php | |
| require_once __DIR__.'/../vendor/autoload.php'; | |
| try { | |
| $env = env('APP_ENV'); | |
| $filename = sprintf(".env.%s", $env); | |
| (new Dotenv\Dotenv(dirname(__DIR__), $filename))->load(); | |
| } catch (Dotenv\Exception\InvalidPathException $e) { | |
| echo ".env for test is missing."; | |
| exit(1); | |
| } | |
| require_once 'bootstrap/app.php'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <phpunit backupGlobals="false" | |
| backupStaticAttributes="false" | |
| bootstrap="tests/autoload.php" // here! | |
| colors="true" | |
| convertErrorsToExceptions="true" | |
| convertNoticesToExceptions="true" | |
| convertWarningsToExceptions="true" | |
| processIsolation="false" | |
| stopOnFailure="false"> | |
| <testsuites> | |
| <testsuite name="Application Test Suite"> | |
| <directory suffix="Test.php">./tests</directory> | |
| </testsuite> | |
| </testsuites> | |
| <filter> | |
| <whitelist processUncoveredFilesFromWhitelist="true"> | |
| <directory suffix=".php">./app</directory> | |
| </whitelist> | |
| </filter> | |
| <php> | |
| <env name="APP_ENV" value="testing"/> | |
| <env name="CACHE_DRIVER" value="array"/> | |
| <env name="SESSION_DRIVER" value="array"/> | |
| <env name="QUEUE_DRIVER" value="sync"/> | |
| </php> | |
| </phpunit> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment