make(Kernel::class); /* * Bootstrap the kernel and prepare application for testing. */ $kernel->bootstrap(); $output = new ConsoleOutput; $prefix = 'database.connections.'.config('database.default'); if (! Str::contains(config("$prefix.database"), 'test')) { $output->writeln(PHP_EOL.'Cannot run test process against non-testing database.'); $output->writeln(PHP_EOL.'Environment is currently pointed at: "'.config("$prefix.database").'".'); exit(1); } /* * Perform database migrations and reseeding before continuing with * running the tests. */ if (! env('SKIP_MIGRATIONS')) { $output->writeln(PHP_EOL.'Refreshing database for Integration tests...'); $kernel->call('migrate:fresh'); $output->writeln('Seeding database for Integration tests...'.PHP_EOL); $kernel->call('db:seed'); } else { $output->writeln(PHP_EOL.'Skipping database migrations...'.PHP_EOL); } // Pop the error and exception handlers the bootstrap-level application installed so // PHPUnit starts from a clean handler baseline; each test boots its own application. restore_error_handler(); restore_exception_handler();