Files
AndyTranscribe/tests/Feature/DemoUserSeederTest.php
T
ben bfcfc12f58 Add Fortify auth, Flux dark mode, demo seed, and Docker hot reload.
Protect recordings per user, seed a demo login on container start, and bind-mount the app with Vite HMR for local Compose development.
2026-08-12 18:38:53 +02:00

54 lines
1.5 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\Recording;
use App\Models\User;
use Database\Seeders\DatabaseSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
use Tests\TestCase;
class DemoUserSeederTest extends TestCase
{
use RefreshDatabase;
public function test_seeder_creates_demo_user(): void
{
$this->seed(DatabaseSeeder::class);
$user = User::query()->where('email', 'demo@example.com')->first();
$this->assertNotNull($user);
$this->assertSame('Demo User', $user->name);
$this->assertTrue(Hash::check('password', $user->password));
}
public function test_seeder_is_idempotent(): void
{
$this->seed(DatabaseSeeder::class);
$this->seed(DatabaseSeeder::class);
$this->assertSame(1, User::query()->where('email', 'demo@example.com')->count());
}
public function test_seeder_assigns_orphaned_recordings_to_demo_user(): void
{
Recording::query()->create([
'title' => 'Orphan',
'original_filename' => 'orphan.mp3',
'file_path' => 'recordings/orphan.mp3',
'file_size_bytes' => 10,
'transcription_status' => 'pending',
'user_id' => null,
]);
$this->seed(DatabaseSeeder::class);
$user = User::query()->where('email', 'demo@example.com')->first();
$this->assertNotNull($user);
$this->assertSame($user->id, Recording::query()->where('title', 'Orphan')->value('user_id'));
}
}