<?php

namespace Tests\Feature\Ticket;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Schema;
use Tests\TestCase;

class TicketValiditySchemaTest extends TestCase
{
    use RefreshDatabase;

    public function test_ticket_validity_time_schema_is_available(): void
    {
        $this->assertEqualsCanonicalizing([
            'id',
            'type',
            'start_time',
            'end_time',
            'fixed_starts_at',
            'fixed_expires_at',
            'created_at',
            'updated_at',
        ], Schema::getColumnListing('validity_times'));

        $this->assertFalse(Schema::hasColumn('tickets', 'validity_time_id'));
        $this->assertFalse(Schema::hasTable('ticket_validity_times'));
        $this->assertFalse(Schema::hasTable('ticket_validity_groups'));
        $this->assertFalse(Schema::hasTable('ticket_validity_group_times'));
        $this->assertFalse(Schema::hasColumn('tickets', 'service_date'));
        $this->assertFalse(Schema::hasColumn('tickets', 'starts_at'));
        $this->assertFalse(Schema::hasColumn('tickets', 'expires_at'));

        $this->assertFalse(Schema::hasColumn('catalog_items', 'validity_time_id'));
        $this->assertFalse(Schema::hasColumn('catalog_items', 'minimum_use_date'));
        $this->assertFalse(Schema::hasColumn('catalog_items', 'maximum_use_date'));
        $this->assertTrue(Schema::hasColumn('catalog_items', 'deleted_at'));
        $this->assertTrue(Schema::hasColumn('attribute_options', 'validity_time_id'));
        $this->assertTrue(Schema::hasColumn('event_dates', 'validity_time_id'));
        $this->assertFalse(Schema::hasColumn('variantes', 'minimum_use_date'));
        $this->assertFalse(Schema::hasColumn('variantes', 'maximum_use_date'));
        $this->assertTrue(Schema::hasColumn('variantes', 'deleted_at'));
    }
}
