pp-planer/tests/Feature/DatabaseSchemaTest.php

68 lines
1.9 KiB
PHP

<?php
use App\Models\CtsSyncLog;
use App\Models\Service;
use App\Models\ServiceSong;
use App\Models\Slide;
use App\Models\Song;
use App\Models\SongArrangement;
use App\Models\SongSlide;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Schema;
uses(RefreshDatabase::class);
test('all expected database tables exist', function () {
$expectedTables = [
'users',
'password_reset_tokens',
'sessions',
'cache',
'cache_locks',
'jobs',
'job_batches',
'failed_jobs',
'services',
'songs',
'labels',
'song_slides',
'song_arrangements',
'song_arrangement_labels',
'service_songs',
'slides',
'cts_sync_log',
'macros',
'macro_collections',
'macro_assignments',
'service_macro_overrides',
'service_macro_assignments',
];
foreach ($expectedTables as $table) {
expect(Schema::hasTable($table))->toBeTrue("Table [{$table}] should exist.");
}
});
test('dropped tables no longer exist', function () {
expect(Schema::hasTable('song_groups'))->toBeFalse();
expect(Schema::hasTable('song_arrangement_groups'))->toBeFalse();
});
test('all factories create valid records', function () {
Service::factory()->create();
Song::factory()->create();
SongSlide::factory()->create();
SongArrangement::factory()->create();
ServiceSong::factory()->create();
Slide::factory()->create();
CtsSyncLog::factory()->create();
expect(Service::count())->toBeGreaterThan(0)
->and(Song::count())->toBeGreaterThan(0)
->and(SongSlide::count())->toBeGreaterThan(0)
->and(SongArrangement::count())->toBeGreaterThan(0)
->and(ServiceSong::count())->toBeGreaterThan(0)
->and(Slide::count())->toBeGreaterThan(0)
->and(CtsSyncLog::count())->toBeGreaterThan(0);
});