<?php

declare(strict_types=1);

namespace Drupal\Tests\flowdrop_stategraph\Unit\ApprovalGate;

use Drupal\Tests\UnitTestCase;
use Drupal\flowdrop_stategraph\ApprovalGate\ApprovalStatus;
use Drupal\Tests\flowdrop\Unit\Traits\EnumContractTestTrait;

/**
 * Tests the ApprovalStatus enum.
 *
 * @coversDefaultClass \Drupal\flowdrop_stategraph\ApprovalGate\ApprovalStatus
 * @group flowdrop_stategraph
 */
class ApprovalStatusTest extends UnitTestCase {

  use EnumContractTestTrait;

  /**
   * @covers \Drupal\flowdrop_stategraph\ApprovalGate\ApprovalStatus
   */
  public function testCasesAndValues(): void {
    $this->assertBackedEnumValues(ApprovalStatus::class, [
      'Pending' => 'pending',
      'Approved' => 'approved',
      'Rejected' => 'rejected',
      'Timeout' => 'timeout',
    ]);
  }

  /**
   * @covers ::label
   */
  public function testLabels(): void {
    $this->assertEquals('Pending Approval', ApprovalStatus::Pending->label());
    $this->assertEquals('Approved', ApprovalStatus::Approved->label());
    $this->assertEquals('Rejected', ApprovalStatus::Rejected->label());
    $this->assertEquals('Timed Out', ApprovalStatus::Timeout->label());
  }

  /**
   * @covers ::isTerminal
   */
  public function testIsTerminal(): void {
    $this->assertFalse(ApprovalStatus::Pending->isTerminal());
    $this->assertTrue(ApprovalStatus::Approved->isTerminal());
    $this->assertTrue(ApprovalStatus::Rejected->isTerminal());
    $this->assertTrue(ApprovalStatus::Timeout->isTerminal());
  }

  /**
   * @covers ::allowsContinuation
   */
  public function testAllowsContinuation(): void {
    $this->assertFalse(ApprovalStatus::Pending->allowsContinuation());
    $this->assertTrue(ApprovalStatus::Approved->allowsContinuation());
    $this->assertFalse(ApprovalStatus::Rejected->allowsContinuation());
    $this->assertFalse(ApprovalStatus::Timeout->allowsContinuation());
  }

}
