<?php

declare(strict_types=1);

namespace Drupal\Tests\peach\Kernel;

use Drupal\KernelTests\KernelTestBase;
use PHPUnit\Framework\Attributes\Group;

/**
 * Tests generated module.
 */
#[Group('DCG')]
final class ModuleTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = ['peach'];

  /**
   * Test callback.
   */
  public function testModule(): void {
    $module = $this->container
      ->get('module_handler')
      ->getModule('peach');
    self::assertSame('module', $module->getType());
    self::assertSame('peach', $module->getName());
    self::assertSame('peach.info.yml', $module->getFilename());
  }

  /**
   * Test callback.
   */
  public function testInfo(): void {
    $info = $this->container
      ->get('extension.list.module')
      ->getExtensionInfo('peach');
    $expected_info = [
      'name' => 'Peach',
      'type' => 'module',
      'description' => 'Simple module generated by DCG.',
      'package' => 'DCG',
      'core_version_requirement' => '^10 || ^11',
      'dependencies' => [
        'drupal:node',
        'drupal:views',
      ],
      'core_incompatible' => FALSE,
      'lifecycle' => 'stable',
      'version' => NULL,
      'php' => '8.3.0',
    ];
    unset($info['mtime']);
    self::assertSame($expected_info, $info);
  }

}
