2018-11-05 00:24:05 +01:00
|
|
|
<?php
|
2018-11-06 20:08:28 +01:00
|
|
|
|
2018-11-05 00:24:05 +01:00
|
|
|
namespace Tests\Unit\Entity\Subscriber;
|
|
|
|
|
|
|
|
use Symfony\Component\Translation\Translator;
|
2019-02-17 14:33:19 +01:00
|
|
|
use Infinito\Event\Menu\MenuEvent;
|
2018-11-05 00:24:05 +01:00
|
|
|
use Symfony\Component\HttpFoundation\RequestStack;
|
2018-11-06 20:07:21 +01:00
|
|
|
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;
|
2018-11-05 00:24:05 +01:00
|
|
|
|
2019-03-29 15:50:52 +01:00
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
|
|
|
class UserMenuSubscriberTest extends KernelTestCase
|
2018-11-05 00:24:05 +01:00
|
|
|
{
|
|
|
|
/**
|
2019-03-29 15:50:52 +01:00
|
|
|
* @var UserMenuSubscriber
|
2018-11-05 00:24:05 +01:00
|
|
|
*/
|
|
|
|
public $subscriber;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
2019-03-29 15:50:52 +01:00
|
|
|
self::bootKernel();
|
2018-11-05 00:24:05 +01:00
|
|
|
$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-05 00:24:05 +01:00
|
|
|
}
|
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
|
|
|
{
|
2018-11-06 20:07:21 +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));
|
2018-11-05 00:24:05 +01:00
|
|
|
}
|
|
|
|
}
|