<?php

declare(strict_types=1);

namespace Drupal\Tests\flowdrop_trigger\Unit\Enum;

use Drupal\Tests\UnitTestCase;
use Drupal\flowdrop_trigger\Enum\TriggerExecutionMode;
use Drupal\Tests\flowdrop\Unit\Traits\EnumContractTestTrait;

/**
 * Tests the TriggerExecutionMode enum.
 *
 * @coversDefaultClass \Drupal\flowdrop_trigger\Enum\TriggerExecutionMode
 * @group flowdrop_trigger
 */
class TriggerExecutionModeTest extends UnitTestCase {

  use EnumContractTestTrait;

  /**
   * @covers \Drupal\flowdrop_trigger\Enum\TriggerExecutionMode
   */
  public function testCasesAndValues(): void {
    $this->assertBackedEnumValues(TriggerExecutionMode::class, [
      'Sync' => 'sync',
      'Async' => 'async',
    ]);
  }

  /**
   * @covers ::label
   */
  public function testLabels(): void {
    $this->assertEquals('Synchronous', TriggerExecutionMode::Sync->label());
    $this->assertEquals('Asynchronous', TriggerExecutionMode::Async->label());
  }

  /**
   * Tests from string construction.
   */
  public function testFromString(): void {
    $this->assertSame(TriggerExecutionMode::Sync, TriggerExecutionMode::from('sync'));
    $this->assertSame(TriggerExecutionMode::Async, TriggerExecutionMode::from('async'));
  }

}
