mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
fix cs
This commit is contained in:
@@ -22,6 +22,52 @@ use Symfony\Component\Security\Core\Role\Role;
|
||||
*/
|
||||
final class ActivityControllerTest extends WebTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getSecuredPagesUnauthenticated
|
||||
*/
|
||||
public function testAccessIsDeniedForUnauthenticated(mixed $url)
|
||||
{
|
||||
$client = $this->createClient();
|
||||
|
||||
$client->request('GET', $url);
|
||||
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
$this->assertTrue(
|
||||
$client->getResponse()->isRedirect('http://localhost/login'),
|
||||
sprintf('the page "%s" does not redirect to http://localhost/login', $url)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a client unauthenticated and.
|
||||
*/
|
||||
public function getSecuredPagesUnauthenticated()
|
||||
{
|
||||
self::bootKernel();
|
||||
$person = $this->getPersonFromFixtures();
|
||||
$activities = $this->getActivitiesForPerson($person);
|
||||
|
||||
return [
|
||||
[sprintf('fr/person/%d/activity/', $person->getId())],
|
||||
[sprintf('fr/person/%d/activity/new', $person->getId())],
|
||||
[sprintf('fr/person/%d/activity/%d/show', $person->getId(), $activities[0]->getId())],
|
||||
[sprintf('fr/person/%d/activity/%d/edit', $person->getId(), $activities[0]->getId())],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getSecuredPagesAuthenticated
|
||||
*
|
||||
* @param type $client
|
||||
* @param type $url
|
||||
*/
|
||||
public function testAccessIsDeniedForUnauthorized($client, $url)
|
||||
{
|
||||
$client->request('GET', $url);
|
||||
|
||||
$this->assertEquals(403, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function getSecuredPagesAuthenticated()
|
||||
{
|
||||
self::bootKernel();
|
||||
@@ -55,52 +101,6 @@ final class ActivityControllerTest extends WebTestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a client unauthenticated and.
|
||||
*/
|
||||
public function getSecuredPagesUnauthenticated()
|
||||
{
|
||||
self::bootKernel();
|
||||
$person = $this->getPersonFromFixtures();
|
||||
$activities = $this->getActivitiesForPerson($person);
|
||||
|
||||
return [
|
||||
[sprintf('fr/person/%d/activity/', $person->getId())],
|
||||
[sprintf('fr/person/%d/activity/new', $person->getId())],
|
||||
[sprintf('fr/person/%d/activity/%d/show', $person->getId(), $activities[0]->getId())],
|
||||
[sprintf('fr/person/%d/activity/%d/edit', $person->getId(), $activities[0]->getId())],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getSecuredPagesUnauthenticated
|
||||
*/
|
||||
public function testAccessIsDeniedForUnauthenticated(mixed $url)
|
||||
{
|
||||
$client = $this->createClient();
|
||||
|
||||
$client->request('GET', $url);
|
||||
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
$this->assertTrue(
|
||||
$client->getResponse()->isRedirect('http://localhost/login'),
|
||||
sprintf('the page "%s" does not redirect to http://localhost/login', $url)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getSecuredPagesAuthenticated
|
||||
*
|
||||
* @param type $client
|
||||
* @param type $url
|
||||
*/
|
||||
public function testAccessIsDeniedForUnauthorized($client, $url)
|
||||
{
|
||||
$client->request('GET', $url);
|
||||
|
||||
$this->assertEquals(403, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testCompleteScenario()
|
||||
{
|
||||
// Create a new client to browse the application
|
||||
|
Reference in New Issue
Block a user