File tree Expand file tree Collapse file tree
tests/FunctionalTests/Controller/Dashboard Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace CodedMonkey \Dirigent \Tests \FunctionalTests \Controller \Dashboard ;
4+
5+ use CodedMonkey \Dirigent \Kernel ;
6+ use CodedMonkey \Dirigent \Tests \Helper \WebTestCaseTrait ;
7+ use Symfony \Bundle \FrameworkBundle \Test \WebTestCase ;
8+ use Symfony \Component \HttpFoundation \Response ;
9+
10+ class DashboardRootControllerPermissionsTest extends WebTestCase
11+ {
12+ use WebTestCaseTrait;
13+
14+ public function testAdministratorHasAdminMenu (): void
15+ {
16+ $ client = static ::createClient ();
17+ $ this ->loginUser ('admin ' );
18+
19+ $ client ->request ('GET ' , '/ ' );
20+
21+ $ this ->assertResponseStatusCodeSame (Response::HTTP_OK );
22+
23+ $ this ->assertAnySelectorTextSame ('.menu-item-label ' , 'Administration ' );
24+ }
25+
26+ public function testUserDoesNotHaveAdminMenu (): void
27+ {
28+ $ client = static ::createClient ();
29+ $ this ->loginUser ();
30+
31+ $ client ->request ('GET ' , '/ ' );
32+
33+ $ this ->assertResponseStatusCodeSame (Response::HTTP_OK );
34+
35+ $ this ->assertAnySelectorTextNotContains ('.menu-item-label ' , 'Administration ' );
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace CodedMonkey \Dirigent \Tests \FunctionalTests \Controller \Dashboard ;
4+
5+ use CodedMonkey \Dirigent \Kernel ;
6+ use CodedMonkey \Dirigent \Tests \Helper \WebTestCaseTrait ;
7+ use Symfony \Bundle \FrameworkBundle \Test \WebTestCase ;
8+ use Symfony \Component \HttpFoundation \Response ;
9+
10+ class DashboardUserControllerTest extends WebTestCase
11+ {
12+ use WebTestCaseTrait;
13+
14+ public function testUserDoesNotHaveAccess (): void
15+ {
16+ $ client = static ::createClient ();
17+ $ this ->loginUser ();
18+
19+ $ client ->request ('GET ' , '/users ' );
20+
21+ $ this ->assertResponseStatusCodeSame (Response::HTTP_UNAUTHORIZED );
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments