<?php

declare(strict_types=1);

namespace Drupal\Tests\flowdrop\Unit\DTO;

use Drupal\Tests\UnitTestCase;
use Drupal\flowdrop\DTO\ValidationWarning;
use Drupal\Tests\flowdrop\Unit\Traits\DtoContractTestTrait;

/**
 * Tests the ValidationWarning DTO.
 *
 * @coversDefaultClass \Drupal\flowdrop\DTO\ValidationWarning
 * @group flowdrop
 */
class ValidationWarningTest extends UnitTestCase {

  use DtoContractTestTrait;

  /**
   * @covers ::__construct
   * @covers ::getParameter
   * @covers ::getMessage
   */
  public function testConstructorAndGetters(): void {
    $warning = new ValidationWarning("timeout", "Value seems high");
    $this->assertEquals("timeout", $warning->getParameter());
    $this->assertEquals("Value seems high", $warning->getMessage());
  }

  /**
   * @covers ::toArray
   */
  public function testToArray(): void {
    $warning = new ValidationWarning("retries", "Consider lowering");
    $this->assertEquals([
      "parameter" => "retries",
      "message" => "Consider lowering",
    ], $warning->toArray());
  }

  /**
   * @covers ::fromArray
   * @covers ::toArray
   */
  public function testRoundTrip(): void {
    $warning = new ValidationWarning("delay", "High value");
    $this->assertRoundTripSerialization($warning);
  }

}
