1 | <?php |
||
9 | class MatcherIntegrationTest extends TestCase |
||
10 | { |
||
11 | /** |
||
12 | * @var \Netgen\Bundle\SiteAccessRoutesBundle\Matcher\Matcher |
||
13 | */ |
||
14 | protected $matcher; |
||
15 | |||
16 | public function setUp() |
||
17 | { |
||
18 | $this->matcher = new Matcher( |
||
19 | array( |
||
20 | new Voter\DefaultSiteAccessVoter('eng'), |
||
21 | new Voter\SiteAccessVoter(), |
||
22 | new Voter\SiteAccessGroupVoter( |
||
23 | array( |
||
24 | 'eng' => array('frontend'), |
||
25 | 'cro' => array('frontend'), |
||
26 | 'admin' => array('backend'), |
||
27 | ) |
||
28 | ), |
||
29 | ) |
||
30 | ); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @param string $siteAccess |
||
35 | * @param array $routeConfig |
||
36 | * @param bool $isAllowed |
||
37 | * |
||
38 | * @covers \Netgen\Bundle\SiteAccessRoutesBundle\Matcher\Matcher::__construct |
||
39 | * @covers \Netgen\Bundle\SiteAccessRoutesBundle\Matcher\Matcher::isAllowed |
||
40 | * |
||
41 | * @dataProvider isAllowedProvider |
||
42 | */ |
||
43 | public function testIsAllowed($siteAccess, array $routeConfig, $isAllowed) |
||
44 | { |
||
45 | $this->assertEquals($isAllowed, $this->matcher->isAllowed($siteAccess, $routeConfig)); |
||
46 | } |
||
47 | |||
48 | public function isAllowedProvider() |
||
49 | { |
||
50 | return array( |
||
51 | array('eng', array('eng'), true), |
||
52 | array('cro', array('eng'), false), |
||
53 | array('extra', array('eng'), false), |
||
54 | |||
55 | array('eng', array('cro'), false), |
||
56 | array('cro', array('cro'), true), |
||
57 | array('extra', array('cro'), false), |
||
58 | |||
59 | array('eng', array('_default'), true), |
||
60 | array('cro', array('_default'), false), |
||
61 | array('extra', array('_default'), false), |
||
62 | |||
63 | array('eng', array('eng', 'backend'), true), |
||
64 | array('cro', array('eng', 'backend'), false), |
||
65 | array('admin', array('eng', 'backend'), true), |
||
66 | array('extra', array('eng', 'backend'), false), |
||
67 | |||
68 | array('eng', array('_default', 'backend'), true), |
||
69 | array('cro', array('_default', 'backend'), false), |
||
70 | array('admin', array('_default', 'backend'), true), |
||
71 | array('extra', array('_default', 'backend'), false), |
||
72 | |||
73 | array('eng', array('_default', 'cro'), true), |
||
74 | array('cro', array('_default', 'cro'), true), |
||
75 | array('admin', array('_default', 'cro'), false), |
||
76 | array('extra', array('_default', 'cro'), false), |
||
77 | ); |
||
78 | } |
||
79 | } |
||
80 |