mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 19:48:49 +02:00
N°2651 rollback gitignore for lib tests dirs
Too dangerous ! We'll work properly on this but for 2.8
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
class GlobalVariablesTest extends TestCase
|
||||
{
|
||||
private $container;
|
||||
private $globals;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->container = new Container();
|
||||
$this->globals = new GlobalVariables($this->container);
|
||||
}
|
||||
|
||||
public function testGetTokenNoTokenStorage()
|
||||
{
|
||||
$this->assertNull($this->globals->getToken());
|
||||
}
|
||||
|
||||
public function testGetTokenNoToken()
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
|
||||
$this->container->set('security.token_storage', $tokenStorage);
|
||||
$this->assertNull($this->globals->getToken());
|
||||
}
|
||||
|
||||
public function testGetToken()
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
|
||||
|
||||
$this->container->set('security.token_storage', $tokenStorage);
|
||||
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->willReturn('token');
|
||||
|
||||
$this->assertSame('token', $this->globals->getToken());
|
||||
}
|
||||
|
||||
public function testGetUserNoTokenStorage()
|
||||
{
|
||||
$this->assertNull($this->globals->getUser());
|
||||
}
|
||||
|
||||
public function testGetUserNoToken()
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
|
||||
$this->container->set('security.token_storage', $tokenStorage);
|
||||
$this->assertNull($this->globals->getUser());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getUserProvider
|
||||
*/
|
||||
public function testGetUser($user, $expectedUser)
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
|
||||
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
|
||||
|
||||
$this->container->set('security.token_storage', $tokenStorage);
|
||||
|
||||
$token
|
||||
->expects($this->once())
|
||||
->method('getUser')
|
||||
->willReturn($user);
|
||||
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->willReturn($token);
|
||||
|
||||
$this->assertSame($expectedUser, $this->globals->getUser());
|
||||
}
|
||||
|
||||
public function getUserProvider()
|
||||
{
|
||||
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
|
||||
$std = new \stdClass();
|
||||
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
|
||||
|
||||
return [
|
||||
[$user, $user],
|
||||
[$std, $std],
|
||||
[$token, $token],
|
||||
['Anon.', null],
|
||||
[null, null],
|
||||
[10, null],
|
||||
[true, null],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user