Skip to content

A self-hosted media server and file management system

feat: php testing config

aminnausinde2aed77dd50
diff --git a/.github/workflows/ci-docker-release.yml b/.github/workflows/ci-docker-release.yml
index 671ed79c..ae4ca5fd 100644
--- a/.github/workflows/ci-docker-release.yml
+++ b/.github/workflows/ci-docker-release.yml
@@ -81,7 +81,7 @@ jobs:
DB_PORT: 5432
DB_PASSWORD: postgres
DB_USERNAME: postgres
- DB_DATABASE: postgres
+ DB_DATABASE: laravel_test
services:
postgres:
@@ -89,7 +89,7 @@ jobs:
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- POSTGRES_DB: postgres
+ POSTGRES_DB: laravel_test
ports:
- 5432:5432
@@ -130,11 +130,16 @@ jobs:
env:
DB_PORT: 5432
+ - name: Execute Frontend tests (Unit and Feature tests) via vitest with coverage
+ run: npm run test:coverage
+ env:
+ NODE_ENV: ci
+
- name: Build
run: npm run build
- - name: Lint
- run: npm run lint -- --fix
+ - name: Lint Frontend
+ run: npm run lint
- name: Execute tests (Unit and Feature tests) via PHPUnit/Pest
run: php artisan test
diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml
index 714fce67..63a6f352 100644
--- a/.github/workflows/ci-test.yml
+++ b/.github/workflows/ci-test.yml
@@ -73,7 +73,7 @@ jobs:
DB_PORT: 5432
DB_PASSWORD: postgres
DB_USERNAME: postgres
- DB_DATABASE: postgres
+ DB_DATABASE: laravel_test
services:
postgres:
@@ -81,7 +81,7 @@ jobs:
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- POSTGRES_DB: postgres
+ POSTGRES_DB: laravel_test
ports:
- 5432:5432
diff --git a/phpunit.xml b/phpunit.xml
index 506b9a38..403d5b6a 100755
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -21,9 +21,13 @@
<env name="APP_ENV" value="testing"/>
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/>
+ <env name="CACHE_DRIVER" value="array"/>
<env name="CACHE_STORE" value="array"/>
- <!-- <env name="DB_CONNECTION" value="sqlite"/> -->
- <!-- <env name="DB_DATABASE" value=":memory:"/> -->
+ <env name="LOG_CHANNEL" value="stderr"/>
+
+ <env name="DB_CONNECTION" value="pgsql"/>
+ <env name="DB_DATABASE" value="laravel_test"/>
+
<env name="MAIL_MAILER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<env name="QUEUE_CONNECTION" value="sync"/>
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 263f1ba0..102362e8 100755
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -5,5 +5,15 @@ namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase {
- //
+ // TODO: use CreatesApplication;
+ // TODO: use RefreshDatabase;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ // 🚨 Safety check to prevent test from wiping real data
+ if (env('DB_DATABASE') === config('app.name')) {
+ throw new \Exception('🚫 Tests are running on your development database! Check DB_DATABASE in .env or phpunit.xml');
+ }
+ }
}