Skip to content

Commit

Permalink
Fix PHPUnit test (AccessControlTest, RolesProviderTest)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimLibaud committed May 17, 2018
1 parent 3b07e07 commit b0d52f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Tests/Role/RolesProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testGetRoles()
$secured_routes = ['route_foo', 'route_bar'];
$routeToRoleConverter = $this->createMock(RouteToRoleConverter::class);
$routeToRoleConverter
->expects(new \PHPUnit_Framework_MockObject_Matcher_InvokedCount(count($secured_routes)))
->expects($this->exactly(count($secured_routes)))
->method('generateRoleForRoute')
->will($this->returnCallback(function ($route) {
return 'ROLE_'.strtoupper($route);
Expand Down
11 changes: 11 additions & 0 deletions Tests/Security/AccessControlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ public function testIsRouteSecure()
$accessControl = $this->createFreshAccessControl();
$this->assertTrue($accessControl->isRouteSecure('admin_home'));
$this->assertFalse($accessControl->isRouteSecure('home_page'));
$this->assertFalse($accessControl->isRouteSecure('api_get_user'));
}

public function testGetAllSecuredRoutes()
{
$accessControl = $this->createFreshAccessControl();
$all_secured_routes = $accessControl->getAllSecuredRoutes();
$this->assertContains('admin_home', $all_secured_routes);
$this->assertContains('admin_dashboard', $all_secured_routes);
$this->assertContains('admin_profile', $all_secured_routes);
$this->assertNotContains('api_get_user', $all_secured_routes);
}

public function testIsEnable()
Expand Down

0 comments on commit b0d52f5

Please sign in to comment.