From b50f314edaf9ad68b4da4742aa10367d9092663e Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 31 May 2018 22:30:05 -0700 Subject: [PATCH] :100: Lets not accidentally drop the entire database again. --- .env.dusk | 11 ++++++----- tests/Browser/BrowserTestCase.php | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.env.dusk b/.env.dusk index 1934ad3d5..4c8e50527 100644 --- a/.env.dusk +++ b/.env.dusk @@ -3,7 +3,7 @@ APP_DEBUG=false APP_KEY=NDWgIKKi9ovNK1PXZpzfNVSBdfCXGb5i APP_JWT_KEY=test1234 APP_TIMEZONE=America/Los_Angeles -APP_URL=http://192.168.1.249 +APP_URL=http://pterodactyl.local CACHE_DRIVER=file SESSION_DRIVER=file @@ -19,7 +19,8 @@ APP_SERVICE_AUTHOR=testing@pterodactyl.io MAIL_FROM_NAME="Pterodactyl Panel" RECAPTCHA_ENABLED=false -DB_HOST=services.pterodactyl.local -DB_DATABASE=panel_test -DB_USERNAME=panel_test -DB_PASSWORD=Test1234 +DB_CONNECTION=testing +TESTING_DB_HOST=services.pterodactyl.local +TESTING_DB_DATABASE=panel_test +TESTING_DB_USERNAME=panel_test +TESTING_DB_PASSWORD=Test1234 diff --git a/tests/Browser/BrowserTestCase.php b/tests/Browser/BrowserTestCase.php index 3e8ae90ae..3e7d08c01 100644 --- a/tests/Browser/BrowserTestCase.php +++ b/tests/Browser/BrowserTestCase.php @@ -3,7 +3,9 @@ namespace Pterodactyl\Tests\Browser; use Laravel\Dusk\TestCase; +use BadMethodCallException; use Tests\CreatesApplication; +use Illuminate\Database\Eloquent\Model; use Facebook\WebDriver\Chrome\ChromeOptions; use Facebook\WebDriver\Remote\RemoteWebDriver; use Facebook\WebDriver\Remote\DesiredCapabilities; @@ -13,6 +15,23 @@ abstract class BrowserTestCase extends TestCase { use CreatesApplication, DatabaseMigrations; + /** + * Setup tests. + */ + protected function setUp() + { + // Don't accidentally run the migrations aganist the non-testing database. Ask me + // how many times I've accidentally dropped my database... + if (env('DB_CONNECTION') !== 'testing') { + throw new BadMethodCallException('Cannot call browser tests using the non-testing database connection.'); + } + + parent::setUp(); + + // Gotta unset this to continue avoiding issues with the validation. + Model::unsetEventDispatcher(); + } + /** * Create the RemoteWebDriver instance. *