<?php

declare(strict_types=1);

use App\Services\Supplier\Dto\SupplierProjectDto;
use Tests\TestCase;

uses(TestCase::class);

test('SupplierProjectDto::equals returns true for same fields regardless of workdays/regions input order', function (): void {
    $dto1 = new SupplierProjectDto(
        platform: 'B1',
        signalType: 'site',
        uniqueKey: 'a.com',
        limit: 5,
        workdays: [1, 2, 3],
        regions: [50, 77],
        regionsReverse: false,
        status: 'active',
    );
    $dto2 = new SupplierProjectDto(
        platform: 'B1',
        signalType: 'site',
        uniqueKey: 'a.com',
        limit: 5,
        workdays: [3, 1, 2],   // same set, different order
        regions: [77, 50],     // same set, different order
        regionsReverse: false,
        status: 'active',
    );

    expect($dto1->equals($dto2))->toBeTrue()
        ->and($dto2->equals($dto1))->toBeTrue();  // symmetry
});

test('SupplierProjectDto::equals returns false when limit differs', function (): void {
    $dto1 = new SupplierProjectDto(
        platform: 'B1',
        signalType: 'site',
        uniqueKey: 'a.com',
        limit: 5,
        workdays: [1, 2, 3],
        regions: [],
        regionsReverse: false,
        status: 'active',
    );
    $dto2 = new SupplierProjectDto(
        platform: 'B1',
        signalType: 'site',
        uniqueKey: 'a.com',
        limit: 6,                // differs
        workdays: [1, 2, 3],
        regions: [],
        regionsReverse: false,
        status: 'active',
    );

    expect($dto1->equals($dto2))->toBeFalse();
});
