libra/tests/Feature/Database/MigrationTest.php

88 lines
2.3 KiB
PHP

<?php
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;
test('all tables exist after migration', function () {
expect(Schema::hasTable('users'))->toBeTrue()
->and(Schema::hasTable('consultations'))->toBeTrue()
->and(Schema::hasTable('timelines'))->toBeTrue()
->and(Schema::hasTable('timeline_updates'))->toBeTrue()
->and(Schema::hasTable('posts'))->toBeTrue()
->and(Schema::hasTable('working_hours'))->toBeTrue()
->and(Schema::hasTable('blocked_times'))->toBeTrue()
->and(Schema::hasTable('notifications'))->toBeTrue()
->and(Schema::hasTable('admin_logs'))->toBeTrue();
});
test('users table has all required columns', function () {
expect(Schema::hasColumns('users', [
'id',
'user_type',
'full_name',
'national_id',
'company_name',
'company_cert_number',
'contact_person_name',
'contact_person_id',
'email',
'phone',
'password',
'status',
'preferred_language',
'email_verified_at',
'remember_token',
'created_at',
'updated_at',
]))->toBeTrue();
});
test('consultations table has all required columns', function () {
expect(Schema::hasColumns('consultations', [
'id',
'user_id',
'booking_date',
'booking_time',
'problem_summary',
'consultation_type',
'payment_amount',
'payment_status',
'status',
'admin_notes',
'created_at',
'updated_at',
]))->toBeTrue();
});
test('timelines table has all required columns', function () {
expect(Schema::hasColumns('timelines', [
'id',
'user_id',
'case_name',
'case_reference',
'status',
'created_at',
'updated_at',
]))->toBeTrue();
});
test('posts table has all required columns', function () {
expect(Schema::hasColumns('posts', [
'id',
'title',
'body',
'status',
'published_at',
'created_at',
'updated_at',
]))->toBeTrue();
});
test('migrate rollback works without errors', function () {
$result = Artisan::call('migrate:rollback', ['--force' => true]);
expect($result)->toBe(0);
$result = Artisan::call('migrate', ['--force' => true]);
expect($result)->toBe(0);
});