<?php

declare(strict_types=1);

namespace Drupal\Tests\flowdrop\Unit\Plugin;

use Drupal\Tests\UnitTestCase;
use Drupal\flowdrop\Plugin\FlowDropNodeProcessor\FlowDropNodeProcessorInterface;
use Drupal\flowdrop\Plugin\FlowDropNodeProcessor\NodeExecutorInterface;
use Drupal\flowdrop\Plugin\FlowDropNodeProcessor\ConfigEditProviderInterface;
use Drupal\Tests\flowdrop\Unit\Traits\InterfaceContractTestTrait;

/**
 * Tests plugin interface method signatures are stable.
 *
 * @group flowdrop
 */
class InterfaceContractTest extends UnitTestCase {

  use InterfaceContractTestTrait;

  /**
   * Tests NodeExecutorInterface contract.
   *
   * @covers \Drupal\flowdrop\Plugin\FlowDropNodeProcessor\NodeExecutorInterface
   */
  public function testNodeExecutorInterface(): void {
    $this->assertInterfaceHasMethod(NodeExecutorInterface::class, 'process', ['params']);
    $this->assertInterfaceMethodCount(NodeExecutorInterface::class, 1);
  }

  /**
   * Tests FlowDropNodeProcessorInterface contract.
   *
   * @covers \Drupal\flowdrop\Plugin\FlowDropNodeProcessor\FlowDropNodeProcessorInterface
   */
  public function testFlowDropNodeProcessorInterface(): void {
    $this->assertInterfaceExtends(
      FlowDropNodeProcessorInterface::class,
      NodeExecutorInterface::class
    );
    $this->assertInterfaceHasMethod(FlowDropNodeProcessorInterface::class, 'getId');
    $this->assertInterfaceHasMethod(FlowDropNodeProcessorInterface::class, 'getName');
    $this->assertInterfaceHasMethod(FlowDropNodeProcessorInterface::class, 'getDescription');
    $this->assertInterfaceHasMethod(FlowDropNodeProcessorInterface::class, 'getVersion');
    $this->assertInterfaceHasMethod(FlowDropNodeProcessorInterface::class, 'validateParams', ['params']);
    $this->assertInterfaceHasMethod(FlowDropNodeProcessorInterface::class, 'getOutputSchema');
    $this->assertInterfaceHasMethod(FlowDropNodeProcessorInterface::class, 'getParameterSchema');
  }

  /**
   * Tests ConfigEditProviderInterface contract.
   *
   * @covers \Drupal\flowdrop\Plugin\FlowDropNodeProcessor\ConfigEditProviderInterface
   */
  public function testConfigEditProviderInterface(): void {
    $this->assertInterfaceHasMethod(ConfigEditProviderInterface::class, 'getConfigEdit');
    $this->assertInterfaceMethodCount(ConfigEditProviderInterface::class, 1);
  }

}
