<?php

declare(strict_types=1);

namespace Drupal\Tests\flowdrop_trigger\Unit\Enum;

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

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

  use EnumContractTestTrait;

  /**
   * @covers \Drupal\flowdrop_trigger\Enum\EventCategory
   */
  public function testCasesAndValues(): void {
    $this->assertBackedEnumValues(EventCategory::class, [
      'Entity' => 'entity',
      'User' => 'user',
      'Form' => 'form',
      'Cron' => 'cron',
      'Integration' => 'integration',
    ]);
  }

  /**
   * @covers ::label
   */
  public function testLabels(): void {
    $this->assertEquals('Entity', EventCategory::Entity->label());
    $this->assertEquals('User', EventCategory::User->label());
    $this->assertEquals('Form', EventCategory::Form->label());
    $this->assertEquals('Cron', EventCategory::Cron->label());
    $this->assertEquals('Integration', EventCategory::Integration->label());
  }

  /**
   * Tests enum can be constructed from string value.
   */
  public function testFromString(): void {
    $this->assertSame(EventCategory::Entity, EventCategory::from('entity'));
    $this->assertSame(EventCategory::Cron, EventCategory::from('cron'));
  }

}
