<?php

declare(strict_types=1);

namespace Drupal\Tests\flowdrop_interrupt\Unit\Enum;

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

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

  use EnumContractTestTrait;

  /**
   * @covers \Drupal\flowdrop_interrupt\Enum\InterruptType
   */
  public function testCasesAndValues(): void {
    $this->assertBackedEnumValues(InterruptType::class, [
      'Confirmation' => 'confirmation',
      'Choice' => 'choice',
      'Text' => 'text',
      'Form' => 'form',
    ]);
  }

  /**
   * @covers ::label
   */
  public function testLabels(): void {
    $this->assertEquals('Confirmation', InterruptType::Confirmation->label());
    $this->assertEquals('Choice', InterruptType::Choice->label());
    $this->assertEquals('Text Input', InterruptType::Text->label());
    $this->assertEquals('Form', InterruptType::Form->label());
  }

  /**
   * @covers ::description
   */
  public function testDescriptions(): void {
    $this->assertNotEmpty(InterruptType::Confirmation->description());
    $this->assertNotEmpty(InterruptType::Choice->description());
    $this->assertNotEmpty(InterruptType::Text->description());
    $this->assertNotEmpty(InterruptType::Form->description());
  }

  /**
   * Tests from string construction.
   */
  public function testFromString(): void {
    $this->assertSame(InterruptType::Confirmation, InterruptType::from('confirmation'));
    $this->assertSame(InterruptType::Form, InterruptType::from('form'));
  }

}
