Completed
Push — master ( d2fb93...a24186 )
by Narcotic
26:10 queued 11:13
created

ServiceAllowedVoterTest::testGetSupportedClasses()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
/**
3
 * Validates the correct behavior of the voter
4
 */
5
namespace Graviton\SecurityBundle\Voter;
6
7
use Graviton\TestBundle\Test\GravitonTestCase;
8
9
/**
10
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
11
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
12
 * @link     http://swisscom.ch
13
 */
14
class ServiceAllowedVoterTest extends GravitonTestCase
15
{
16
    /** @var array  */
17
    private $whitelist = array();
18
19
    /**
20
     * Test setup
21
     *
22
     * @return void
23
     */
24
    protected function setup()
25
    {
26
        $this->whitelist = array('/app/core');
27
    }
28
29
    /**
30
     * verifies isGranted()
31
     *
32
     * @return void
33
     */
34
    public function testIsGranted()
35
    {
36
        $request = $this->getSimpleTestDouble('\Symfony\Component\HttpFoundation\Request', array('getPathInfo'));
37
        $request
38
            ->expects($this->once())
39
            ->method('getPathInfo')
40
            ->willReturn('/app/core');
41
42
        $voter = $this->getProxyBuilder('\Graviton\SecurityBundle\Voter\ServiceAllowedVoter')
43
            ->setConstructorArgs(array($this->whitelist))
44
            ->setMethods(array('voteOnAttribute'))
45
            ->getProxy();
46
47
        $token = $this
48
            ->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')
49
            ->getMock();
50
51
        $this->assertTrue($voter->voteOnAttribute('VIEW', $request, $token));
52
    }
53
}
54