<?php

declare(strict_types=1);

namespace Ferienpass\AdminBundle\Tests\Twig;

use Ferienpass\AdminBundle\Twig\MenuExtension;
use Knp\Menu\ItemInterface;
use Knp\Menu\Twig\Helper;
use PHPUnit\Framework\TestCase;

final class MenuExtensionTest extends TestCase
{
    public function testGetDelegatesToHelper(): void
    {
        $item = new \stdClass();
        $menuItem = $this->createMock(ItemInterface::class);

        $helper = $this->createMock(Helper::class);
        $helper->expects(self::once())
            ->method('get')
            ->with('admin_list_actions', [], ['item' => $item])
            ->willReturn($menuItem);

        $extension = new MenuExtension($helper);
        $result = $extension->get($item);

        self::assertSame($menuItem, $result);
    }

    public function testGetPassesOptionsToHelper(): void
    {
        $item = new \stdClass();
        $menuItem = $this->createMock(ItemInterface::class);

        $helper = $this->createMock(Helper::class);
        $helper->expects(self::once())
            ->method('get')
            ->with('admin_list_actions', ['sub'], ['item' => $item, 'extra' => 'val'])
            ->willReturn($menuItem);

        $extension = new MenuExtension($helper);
        $result = $extension->get($item, ['sub'], ['extra' => 'val']);

        self::assertSame($menuItem, $result);
    }
}
