Bootstrap.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Tests;
  3. use Illuminate\Contracts\Console\Kernel;
  4. use PHPUnit\Runner\AfterLastTestHook;
  5. use PHPUnit\Runner\BeforeFirstTestHook;
  6. class Bootstrap implements BeforeFirstTestHook, AfterLastTestHook
  7. {
  8. /*
  9. |--------------------------------------------------------------------------
  10. | Bootstrap The Test Environment
  11. |--------------------------------------------------------------------------
  12. |
  13. | You may specify console commands that execute once before your test is
  14. | run. You are free to add your own additional commands or logic into
  15. | this file as needed in order to help your test suite run quicker.
  16. |
  17. */
  18. use CreatesApplication;
  19. public function executeBeforeFirstTest(): void
  20. {
  21. $console = $this->createApplication()->make(Kernel::class);
  22. $commands = [
  23. 'config:cache',
  24. 'event:cache',
  25. ];
  26. foreach ($commands as $command) {
  27. $console->call($command);
  28. }
  29. }
  30. public function executeAfterLastTest(): void
  31. {
  32. array_map('unlink', glob('bootstrap/cache/*.phpunit.php'));
  33. }
  34. }