infinito/application/symfony/tests/Unit/Subscriber/UserMenuSubscriberTest.php

45 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2018-11-06 20:08:28 +01:00
namespace Tests\Unit\Entity\Subscriber;
use Symfony\Component\Translation\Translator;
use Infinito\Event\Menu\MenuEvent;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Request;
use Knp\Menu\MenuItem;
use Knp\Menu\MenuFactory;
2019-03-29 15:50:52 +01:00
use Infinito\Subscriber\UserMenuSubscriber;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
2019-03-29 15:50:52 +01:00
/**
* @author kevinfrantz
*/
class UserMenuSubscriberTest extends KernelTestCase
{
/**
2019-03-29 15:50:52 +01:00
* @var UserMenuSubscriber
*/
public $subscriber;
public function setUp(): void
{
2019-03-29 15:50:52 +01:00
self::bootKernel();
$translator = new Translator('en');
2019-03-29 15:50:52 +01:00
$tokenStorage = self::$container->get(TokenStorageInterface::class);
$this->subscriber = new UserMenuSubscriber($tokenStorage, $translator);
}
2018-11-06 20:08:28 +01:00
2019-03-29 15:50:52 +01:00
public function testOnUserMenuConfigure(): void
2018-11-06 20:08:28 +01:00
{
$factory = new MenuFactory();
$item = new MenuItem('test', $factory);
$request = new Request();
$request->attributes->set('id', 123);
$requests = new RequestStack();
$requests->push($request);
$event = new MenuEvent($factory, $item, $requests);
2019-03-29 15:50:52 +01:00
$this->assertNull($this->subscriber->onUserMenuConfigure($event));
}
}