Skip to content

Commit b50f314

Browse files
committed
💯 Lets not accidentally drop the entire database again.
1 parent c86690a commit b50f314

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

.env.dusk

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ APP_DEBUG=false
33
APP_KEY=NDWgIKKi9ovNK1PXZpzfNVSBdfCXGb5i
44
APP_JWT_KEY=test1234
55
APP_TIMEZONE=America/Los_Angeles
6-
APP_URL=http://192.168.1.249
6+
APP_URL=http://pterodactyl.local
77

88
CACHE_DRIVER=file
99
SESSION_DRIVER=file
@@ -19,7 +19,8 @@ APP_SERVICE_AUTHOR=testing@pterodactyl.io
1919
MAIL_FROM_NAME="Pterodactyl Panel"
2020
RECAPTCHA_ENABLED=false
2121

22-
DB_HOST=services.pterodactyl.local
23-
DB_DATABASE=panel_test
24-
DB_USERNAME=panel_test
25-
DB_PASSWORD=Test1234
22+
DB_CONNECTION=testing
23+
TESTING_DB_HOST=services.pterodactyl.local
24+
TESTING_DB_DATABASE=panel_test
25+
TESTING_DB_USERNAME=panel_test
26+
TESTING_DB_PASSWORD=Test1234

tests/Browser/BrowserTestCase.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace Pterodactyl\Tests\Browser;
44

55
use Laravel\Dusk\TestCase;
6+
use BadMethodCallException;
67
use Tests\CreatesApplication;
8+
use Illuminate\Database\Eloquent\Model;
79
use Facebook\WebDriver\Chrome\ChromeOptions;
810
use Facebook\WebDriver\Remote\RemoteWebDriver;
911
use Facebook\WebDriver\Remote\DesiredCapabilities;
@@ -13,6 +15,23 @@ abstract class BrowserTestCase extends TestCase
1315
{
1416
use CreatesApplication, DatabaseMigrations;
1517

18+
/**
19+
* Setup tests.
20+
*/
21+
protected function setUp()
22+
{
23+
// Don't accidentally run the migrations aganist the non-testing database. Ask me
24+
// how many times I've accidentally dropped my database...
25+
if (env('DB_CONNECTION') !== 'testing') {
26+
throw new BadMethodCallException('Cannot call browser tests using the non-testing database connection.');
27+
}
28+
29+
parent::setUp();
30+
31+
// Gotta unset this to continue avoiding issues with the validation.
32+
Model::unsetEventDispatcher();
33+
}
34+
1635
/**
1736
* Create the RemoteWebDriver instance.
1837
*

0 commit comments

Comments
 (0)