ViewportPermissionsTest.php in Viewport 8
File
tests/src/Functional/ViewportPermissionsTest.php
View source
<?php
namespace Drupal\Tests\viewport\Functional;
use Drupal\Tests\BrowserTestBase;
class ViewportPermissionsTest extends BrowserTestBase {
public static $modules = [
'viewport',
];
private $userWithViewportPerm;
private $userWithoutViewportPerm;
public function setUp() {
parent::setUp();
$this->userWithViewportPerm = $this
->drupalCreateUser(array(
'administer viewport',
));
$this->userWithoutViewportPerm = $this
->drupalCreateUser();
}
public function testSettingsPageAccessPermission() {
$viewportSettingsPath = 'admin/appearance/settings/viewport';
$this
->drupalLogin($this->userWithViewportPerm);
$this
->drupalGet($viewportSettingsPath);
$this
->assertEquals(200, $this
->getSession()
->getStatusCode());
$this
->drupalLogin($this->userWithoutViewportPerm);
$this
->drupalGet($viewportSettingsPath);
$this
->assertEquals(403, $this
->getSession()
->getStatusCode());
}
}