<?php

declare(strict_types=1);

namespace Tests\Unit;

use App\Models\ClientAddress;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

/**
 * Tests for ClientAddress::fullAddress() accessor.
 *
 * The collector route cards display this string so the agent can locate
 * the client during the collection run. Verifies the segments are joined
 * as "address_line_1, city, state" and that empty segments are dropped.
 *
 * No database interaction — models are hydrated in memory.
 */
class ClientAddressFullAddressTest extends TestCase
{
    #[Test]
    public function it_joins_all_segments_with_commas(): void
    {
        $address = new ClientAddress([
            'address_line_1' => 'Calle 71 # 21A - 26',
            'city' => 'Soledad',
            'state' => 'Atlántico',
        ]);

        $this->assertSame('Calle 71 # 21A - 26, Soledad, Atlántico', $address->full_address);
    }

    #[Test]
    public function it_omits_empty_segments(): void
    {
        $address = new ClientAddress([
            'address_line_1' => 'Carrera 5',
            'city' => '',
            'state' => 'Bolívar',
        ]);

        $this->assertSame('Carrera 5, Bolívar', $address->full_address);
    }

    #[Test]
    public function it_returns_empty_string_when_no_segments(): void
    {
        $address = new ClientAddress;

        $this->assertSame('', $address->full_address);
    }
}
