<?php

declare(strict_types=1);

namespace Ferienpass\AdminBundle\Tests\Controller\Page;

use Ferienpass\AdminBundle\Controller\Page\ToolsController;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\Attribute\Route;

final class ToolsControllerTest extends TestCase
{
    
    #[DataProvider('expectedRouteNamesProvider')]
    
    public function testRouteNameExists(string $routeName): void
    {
        $ref = new \ReflectionClass(ToolsController::class);
        $routeNames = [];

        foreach ($ref->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
            foreach ($method->getAttributes(Route::class) as $attr) {
                $route = $attr->newInstance();
                if (null !== $route->getName()) {
                    $routeNames[] = $route->getName();
                }
            }
        }

        self::assertContains($routeName, $routeNames);
    }

    public static function expectedRouteNamesProvider(): iterable
    {
        yield 'export' => ['admin_export_index'];
        yield 'mailing' => ['admin_tools_mailing'];
        yield 'settings' => ['admin_tools_settings'];
        yield 'settings general' => ['admin_tools_settings_general'];
        yield 'settings categories' => ['admin_tools_settings_categories'];
        yield 'outbox' => ['admin_outbox'];
        yield 'erase data' => ['admin_erase_data'];
        yield 'access codes' => ['admin_accessCodes_index'];
        yield 'report issue' => ['admin_tools_issue'];
    }
}
