mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Merge pull request #13292 from marcusmoore/guard-against-wiping-local-db
Avoid accidentally wiping local database when running tests
This commit is contained in:
commit
1b8b117f4e
|
@ -21,7 +21,9 @@ pipeline:
|
|||
- name: Setup
|
||||
cmd: |
|
||||
cp -v .env.example .env
|
||||
|
||||
# This is simply to allow passing the guard in TestCase@setUp()
|
||||
# https://chipperci.com/docs/builds/env
|
||||
touch .env.testing
|
||||
composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||
|
||||
- name: Generate Key
|
||||
|
|
|
@ -7,6 +7,7 @@ use Facebook\WebDriver\Remote\DesiredCapabilities;
|
|||
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Laravel\Dusk\TestCase as BaseTestCase;
|
||||
use RuntimeException;
|
||||
|
||||
abstract class DuskTestCase extends BaseTestCase
|
||||
{
|
||||
|
@ -21,6 +22,12 @@ abstract class DuskTestCase extends BaseTestCase
|
|||
*/
|
||||
public static function prepare()
|
||||
{
|
||||
if (!file_exists(realpath(__DIR__ . '/../') . '/.env.dusk.local')) {
|
||||
throw new RuntimeException(
|
||||
'.env.dusk.local file does not exist. Aborting to avoid wiping your local database'
|
||||
);
|
||||
}
|
||||
|
||||
if (! static::runningInSail()) {
|
||||
static::startChromeDriver();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Tests;
|
|||
use App\Http\Middleware\SecurityHeaders;
|
||||
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
use RuntimeException;
|
||||
use Tests\Support\CustomTestMacros;
|
||||
use Tests\Support\InteractsWithAuthentication;
|
||||
use Tests\Support\InteractsWithSettings;
|
||||
|
@ -22,6 +23,12 @@ abstract class TestCase extends BaseTestCase
|
|||
|
||||
protected function setUp(): void
|
||||
{
|
||||
if (!file_exists(realpath(__DIR__ . '/../') . '/.env.testing')) {
|
||||
throw new RuntimeException(
|
||||
'.env.testing file does not exist. Aborting to avoid wiping your local database'
|
||||
);
|
||||
}
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$this->withoutMiddleware($this->globallyDisabledMiddleware);
|
||||
|
|
Loading…
Reference in a new issue