<?php

namespace AutoAdmin\Bundle\Tests\Unit\Seo\EventListener\Traits;

use AutoAdmin\Bundle\Seo\EventListener\Traits\IsNotFrontUrlTrait;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;

class IsNotFrontUrlTraitTest extends TestCase
{
    private function dataProviderIsNotFrontUrl(): array
    {
        return [
            'null route' => [
                null,
                false,
            ],
            'route starts with underscore' => [
                '_some_route',
                false,
            ],
            'route starts with aa_admin_' => [
                'aa_admin_some_route',
                false,
            ],
            'valid front url' => [
                'some_route',
                true,
            ],
        ];
    }

    /**
     * @dataProvider dataProviderIsNotFrontUrl
     */
    public function testIsNotFrontUrl(?string $route, bool $expected): void
    {
        $request = $this->createMock(Request::class);
        $request->method('get')->with('_route')->willReturn($route);

        $trait = $this->getMockForTrait(IsNotFrontUrlTrait::class);

        $this->assertEquals($expected, $trait->isNotFrontUrl($request));
    }
}
