<?php

use App\Models\System\Settings\Payments\PaymentType;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Config;

uses(RefreshDatabase::class);

beforeEach(function () {
    Config::set('ecommerce.api.token', 'test-token');
});

test('can get order available times', function () {
    // Act
    $response = $this->withHeaders([
        'Api-Token' => 'test-token',
        'Accept' => 'application/json',
    ])->getJson('/api/v1/order-time');

    // Assert
    $response->assertOk();
    // Structure depends on OrderRepository::availableTimes() implementation
    // Assuming it returns an array of times or dates
    $this->assertIsArray($response->json('data'));
});

test('can list order payment types', function () {
    // Arrange
    PaymentType::create(['name' => 'Cash']);
    PaymentType::create(['name' => 'Card']);

    // Act
    $response = $this->withHeaders([
        'Api-Token' => 'test-token',
        'Accept' => 'application/json',
    ])->getJson('/api/v1/order-payments');

    // Assert
    $response->assertOk()
        ->assertJsonStructure([
            'data' => [
                '*' => [
                    'id',
                    'name',
                ],
            ],
        ]);

    $this->assertCount(2, $response->json('data'));
});
