-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03ba7be
commit a0cedaa
Showing
4 changed files
with
105 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace App\Tests\Controller; | ||
|
||
use Liip\FunctionalTestBundle\Test\WebTestCase; | ||
use Liip\TestFixturesBundle\Test\FixturesTrait; | ||
|
||
class AdminTest extends WebTestCase { | ||
use FixturesTrait; | ||
|
||
public function testAdminsUserNotAdmin() { | ||
$fixtures = $this->loadFixtures(array( | ||
'App\DataFixtures\Tests\UsersFixture', | ||
'App\DataFixtures\Tests\AgentsFixture', | ||
'App\DataFixtures\Tests\RapportFixture', | ||
)); | ||
|
||
$client = $this->makeAuthenticatedClient(); | ||
|
||
$client->request('GET', '/admin'); | ||
$this->assertStatusCode(301, $client); | ||
|
||
$client->request('GET', '/admin/dashboard'); | ||
$this->assertStatusCode(200, $client); | ||
|
||
$client->request('GET', '/admin/app/navire/list'); | ||
$this->assertStatusCode(403, $client); | ||
|
||
} | ||
|
||
/** | ||
* @dataProvider provideAdminUrls | ||
*/ | ||
public function testAdminsUserAdmin($url) { | ||
$fixtures = $this->loadFixtures(array( | ||
'App\DataFixtures\Tests\UsersFixture', | ||
'App\DataFixtures\Tests\AgentsFixture', | ||
'App\DataFixtures\Tests\RapportFixture', | ||
)); | ||
|
||
$client = $this->makeClientWithCredentials('admin', 'admin'); | ||
|
||
$client->request('GET', '/admin'); | ||
$this->assertStatusCode(301, $client); | ||
|
||
$client->request('GET', '/admin/dashboard'); | ||
$this->assertStatusCode(200, $client); | ||
|
||
$client->request('GET', $url); | ||
$this->assertStatusCode(200, $client); | ||
|
||
} | ||
|
||
public function provideAdminUrls() { | ||
return [ | ||
['/admin/app/navire/list'], | ||
['/admin/app/navire/create'], | ||
['/admin/app/rapport/list'], | ||
['/admin/app/rapport/create'], | ||
['/admin/app/etablissement/list'], | ||
['/admin/app/etablissement/create'], | ||
['/admin/app/moyen/list'], | ||
['/admin/app/moyen/create'], | ||
['/admin/app/zonegeographique/list'], | ||
['/admin/app/zonegeographique/create'], | ||
['/admin/app/agent/list'], | ||
['/admin/app/agent/create'], | ||
['/admin/app/serviceinterministeriel/list'], | ||
['/admin/app/serviceinterministeriel/create'], | ||
['/admin/app/categorieetablissement/list'], | ||
['/admin/app/categorieetablissement/create'], | ||
['/admin/app/categoriecontroleautre/list'], | ||
['/admin/app/categoriecontroleautre/create'], | ||
['/admin/app/tache/list'], | ||
['/admin/app/tache/create'], | ||
['/admin/app/categoriecontrolenavire/list'], | ||
['/admin/app/categoriecontrolenavire/create'], | ||
['/admin/app/loisir/list'], | ||
['/admin/app/loisir/create'], | ||
['/admin/app/categoriemoyen/list'], | ||
['/admin/app/categoriemoyen/create'], | ||
['/admin/app/categoriemethodeciblage/list'], | ||
['/admin/app/categoriemethodeciblage/create'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters