1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Netgen\Bundle\SiteAccessRoutesBundle\Tests\Matcher\Voter; |
4
|
|
|
|
5
|
|
|
use Netgen\Bundle\SiteAccessRoutesBundle\Matcher\Voter\SiteAccessGroupVoter; |
6
|
|
|
use Netgen\Bundle\SiteAccessRoutesBundle\Matcher\Voter\VoterInterface; |
7
|
|
|
use Netgen\Bundle\SiteAccessRoutesBundle\Tests\TestCase; |
8
|
|
|
|
9
|
|
|
class SiteAccessGroupVoterTest extends TestCase |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var \Netgen\Bundle\SiteAccessRoutesBundle\Matcher\Voter\SiteAccessGroupVoter |
13
|
|
|
*/ |
14
|
|
|
protected $voter; |
15
|
|
|
|
16
|
|
|
public function setUp() |
17
|
|
|
{ |
18
|
|
|
$this->voter = new SiteAccessGroupVoter( |
19
|
|
|
array( |
20
|
|
|
'eng' => array('frontend'), |
21
|
|
|
'cro' => array('frontend'), |
22
|
|
|
'admin' => array('backend'), |
23
|
|
|
) |
24
|
|
|
); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param string $siteAccess |
29
|
|
|
* @param array $groupConfig |
30
|
|
|
* @param bool $vote |
31
|
|
|
* |
32
|
|
|
* @covers \Netgen\Bundle\SiteAccessRoutesBundle\Matcher\Voter\SiteAccessGroupVoter::__construct |
33
|
|
|
* @covers \Netgen\Bundle\SiteAccessRoutesBundle\Matcher\Voter\SiteAccessGroupVoter::vote |
34
|
|
|
* |
35
|
|
|
* @dataProvider voteProvider |
36
|
|
|
*/ |
37
|
|
|
public function testVote($siteAccess, array $groupConfig, $vote) |
38
|
|
|
{ |
39
|
|
|
$this->assertEquals($vote, $this->voter->vote($siteAccess, $groupConfig)); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function voteProvider() |
43
|
|
|
{ |
44
|
|
|
return array( |
45
|
|
|
array('cro', array('cro', 'backend'), VoterInterface::ABSTAIN), |
46
|
|
|
array('eng', array('cro', 'backend'), VoterInterface::ABSTAIN), |
47
|
|
|
array('admin', array('cro', 'backend'), true), |
48
|
|
|
array('extra', array('cro', 'backend'), VoterInterface::ABSTAIN), |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|