SimLibaud /
SilRouteSecurityBundle
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Sil\RouteSecurityBundle\Tests\WebProfiler; |
||
| 4 | |||
| 5 | use PHPUnit\Framework\TestCase; |
||
| 6 | use Sil\RouteSecurityBundle\Role\RouteToRoleConverter; |
||
| 7 | use Sil\RouteSecurityBundle\Security\AccessControl; |
||
| 8 | use Sil\RouteSecurityBundle\WebProfiler\RouteSecurityTools; |
||
| 9 | use Symfony\Component\HttpFoundation\Request; |
||
| 10 | use Symfony\Component\HttpFoundation\Response; |
||
| 11 | |||
| 12 | class RouteSecurityToolsTest extends TestCase |
||
| 13 | { |
||
| 14 | public function testCollect() |
||
| 15 | { |
||
| 16 | $accessControl = $this->createMock(AccessControl::class); |
||
| 17 | $accessControl |
||
| 18 | ->method('isEnable') |
||
| 19 | ->willReturn(true); |
||
| 20 | $accessControl |
||
| 21 | ->method('isRouteSecure') |
||
| 22 | ->willReturn(true); |
||
| 23 | $routeToRoleConverter = $this->createMock(RouteToRoleConverter::class); |
||
| 24 | $routeToRoleConverter |
||
| 25 | ->method('generateRoleForRoute') |
||
| 26 | ->willReturn('ROLE_FOO'); |
||
| 27 | |||
| 28 | $routeSecurityTools = new RouteSecurityTools($accessControl, $routeToRoleConverter); |
||
| 29 | $request = $this->createMock(Request::class); |
||
| 30 | $request |
||
| 31 | ->method('get') |
||
| 32 | ->with('_route') |
||
| 33 | ->willReturn('foo'); |
||
| 34 | $response = $this->createMock(Response::class); |
||
| 35 | |||
| 36 | $routeSecurityTools->collect($request, $response); |
||
| 37 | |||
| 38 | $this->assertTrue($routeSecurityTools->isAccessControlEnable()); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 39 | $this->assertTrue($routeSecurityTools->isRouteSecure()); |
||
| 40 | $this->assertEquals('ROLE_FOO', $routeSecurityTools->getRoleForRoute()); |
||
| 41 | $this->assertEquals('sil_route_security.route_security_tools', $routeSecurityTools->getName()); |
||
| 42 | $this->assertNull($routeSecurityTools->reset()); |
||
|
0 ignored issues
–
show
Are you sure the usage of
$routeSecurityTools->reset() targeting Sil\RouteSecurityBundle\...eSecurityTools::reset() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||
| 43 | } |
||
| 44 | } |
||
| 45 |