Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / system / tests / src / Functional / Routing / RouterPermissionTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Routing;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Function Tests for the routing permission system.
9  *
10  * @group Routing
11  */
12 class RouterPermissionTest extends BrowserTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['router_test'];
20
21   /**
22    * Tests permission requirements on routes.
23    */
24   public function testPermissionAccess() {
25     $path = 'router_test/test7';
26     $this->drupalGet($path);
27     $this->assertResponse(403, "Access denied for a route where we don't have a permission");
28
29     $this->drupalGet('router_test/test8');
30     $this->assertResponse(403, 'Access denied by default if no access specified');
31
32     $user = $this->drupalCreateUser(['access test7']);
33     $this->drupalLogin($user);
34     $this->drupalGet('router_test/test7');
35     $this->assertResponse(200);
36     $this->assertNoRaw('Access denied');
37     $this->assertRaw('test7text', 'The correct string was returned because the route was successful.');
38   }
39
40 }