Last active
October 13, 2017 21:33
-
-
Save deleugpn/ed996e19b38ae606d9a09f6613cca19d to your computer and use it in GitHub Desktop.
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 | |
| namespace Tests; | |
| use Illuminate\Contracts\Console\Kernel; | |
| use RuntimeException; | |
| trait CreatesApplication | |
| { | |
| protected $allowedHosts = ['', '127.0.0.1', 'localhost']; | |
| /** | |
| * Creates the application. | |
| * | |
| * @return \Illuminate\Foundation\Application | |
| */ | |
| public function createApplication() | |
| { | |
| $app = require __DIR__.'/../bootstrap/app.php'; | |
| $app->make(Kernel::class)->bootstrap(); | |
| $this->protectDatabase(); | |
| return $app; | |
| } | |
| private function protectDatabase() | |
| { | |
| $host = config('database.connections.main.host'); | |
| if (! in_array($host, $this->allowedHosts)) { | |
| throw new RuntimeException("$host not allowed. Please change your phpunit.xml setup."); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment