Passed
Branch master (d32ce5)
by Simon
01:58
created

RolesProviderTest::testGetRoles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 10
cts 10
cp 1
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Sil\RouteSecurityBundle\Tests\Role;
4
5
use PHPUnit\Framework\TestCase;
6
use Sil\RouteSecurityBundle\Role\RolesProvider;
7
use Sil\RouteSecurityBundle\Role\RouteToRoleConverter;
8
9
class RolesProviderTest extends TestCase
10
{
11 1
    public function testGetRoles()
12
    {
13 1
        $secured_routes = ['route_foo', 'route_bar'];
14 1
        $routeToRoleConverter = $this->createMock(RouteToRoleConverter::class);
15
        $routeToRoleConverter
16 1
            ->expects(new \PHPUnit_Framework_MockObject_Matcher_InvokedCount(count($secured_routes)))
17 1
            ->method('generateRoleForRoute')
18 1
            ->will($this->returnCallback(function ($route) {
19 1
                return 'ROLE_'.strtoupper($route);
20 1
            }));
21 1
        $rolesProvider = new RolesProvider($routeToRoleConverter, $secured_routes);
22 1
        $this->assertEquals(['ROLE_ROUTE_FOO', 'ROLE_ROUTE_BAR'], $rolesProvider->getRoles());
23 1
    }
24
}
25