<?php

declare(strict_types=1);

namespace Drupal\Tests\flowdrop_interrupt\Unit\Enum;

use Drupal\Tests\UnitTestCase;
use Drupal\flowdrop_interrupt\Enum\InterruptStatus;
use Drupal\Tests\flowdrop\Unit\Traits\EnumContractTestTrait;

/**
 * Tests the InterruptStatus enum.
 *
 * @coversDefaultClass \Drupal\flowdrop_interrupt\Enum\InterruptStatus
 * @group flowdrop_interrupt
 */
class InterruptStatusTest extends UnitTestCase {

  use EnumContractTestTrait;

  /**
   * @covers \Drupal\flowdrop_interrupt\Enum\InterruptStatus
   */
  public function testCasesAndValues(): void {
    $this->assertBackedEnumValues(InterruptStatus::class, [
      'Pending' => 'pending',
      'Resolved' => 'resolved',
      'Expired' => 'expired',
      'Cancelled' => 'cancelled',
      'Acknowledged' => 'acknowledged',
    ]);
  }

  /**
   * @covers ::label
   */
  public function testLabels(): void {
    $this->assertEquals('Pending', InterruptStatus::Pending->label());
    $this->assertEquals('Resolved', InterruptStatus::Resolved->label());
    $this->assertEquals('Expired', InterruptStatus::Expired->label());
    $this->assertEquals('Cancelled', InterruptStatus::Cancelled->label());
    $this->assertEquals('Acknowledged', InterruptStatus::Acknowledged->label());
  }

  /**
   * @covers ::isTerminal
   */
  public function testIsTerminal(): void {
    $this->assertFalse(InterruptStatus::Pending->isTerminal());
    $this->assertTrue(InterruptStatus::Resolved->isTerminal());
    $this->assertTrue(InterruptStatus::Expired->isTerminal());
    $this->assertTrue(InterruptStatus::Cancelled->isTerminal());
    $this->assertTrue(InterruptStatus::Acknowledged->isTerminal());
  }

  /**
   * @covers ::canResolve
   */
  public function testCanResolve(): void {
    $this->assertTrue(InterruptStatus::Pending->canResolve());
    $this->assertFalse(InterruptStatus::Resolved->canResolve());
    $this->assertFalse(InterruptStatus::Expired->canResolve());
    $this->assertFalse(InterruptStatus::Cancelled->canResolve());
    $this->assertFalse(InterruptStatus::Acknowledged->canResolve());
  }

}
