1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* |
5
|
|
|
* (c) Yaroslav Honcharuk <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Yarhon\RouteGuardBundle\Tests\Functional; |
12
|
|
|
|
13
|
|
|
use Symfony\Bundle\TwigBundle\TwigBundle; |
14
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @runTestsInSeparateProcesses |
18
|
|
|
* |
19
|
|
|
* @author Yaroslav Honcharuk <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class SensioExtraTest extends WebTestCase |
22
|
|
|
{ |
23
|
|
|
protected static $bundles = [ |
24
|
|
|
TwigBundle::class, |
25
|
|
|
SensioFrameworkExtraBundle::class, |
26
|
|
|
Bundle\SensioExtraBundle\SensioExtraBundle::class, |
27
|
|
|
]; |
28
|
|
|
|
29
|
|
|
protected static $configs = [ |
30
|
|
|
'framework' => [ |
31
|
|
|
'router' => [ |
32
|
|
|
'resource' => '@SensioExtraBundle/routes.yaml', |
33
|
|
|
], |
34
|
|
|
], |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
protected static $users = [ |
38
|
|
|
'bob' => ['password' => 'pa$$word', 'roles' => 'ROLE_USER'], |
39
|
|
|
]; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @dataProvider linkDataProvider |
43
|
|
|
*/ |
44
|
|
|
public function testLink($user, $route, $expected) |
45
|
|
|
{ |
46
|
|
|
$link = $this->requestLink($user, $route); |
47
|
|
|
$this->assertEquals($expected, $link->html()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function linkDataProvider() |
51
|
|
|
{ |
52
|
|
|
return [ |
53
|
|
|
[null, ['public'], 'http://example.com/public'], |
54
|
|
|
['bob', ['public'], 'http://example.com/public'], |
55
|
|
|
|
56
|
|
|
[null, ['is_granted_user_role'], 'No access'], |
57
|
|
|
['bob', ['is_granted_user_role'], 'http://example.com/is_granted/user_role'], |
58
|
|
|
|
59
|
|
|
[null, ['security_user_role'], 'No access'], |
60
|
|
|
['bob', ['security_user_role'], 'http://example.com/security/user_role'], |
61
|
|
|
|
62
|
|
|
['bob', ['is_granted_admin_role'], 'No access'], |
63
|
|
|
['bob', ['security_admin_role'], 'No access'], |
64
|
|
|
|
65
|
|
|
[null, ['security_controller_argument', ['argument' => 5]], 'No access'], |
66
|
|
|
[null, ['security_controller_argument', ['argument' => 10]], 'http://example.com/security/controller_argument/10'], |
67
|
|
|
]; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|