Completed
Push — master ( 18bc97...e7bdcd )
by Yaroslav
09:10
created

SensioExtraTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 24
dl 0
loc 46
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testLink() 0 4 1
A linkDataProvider() 0 17 1
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