EntityUpdateUIAccessTest.php in Entity Update 8
File
modules/entity_update_tests/src/Tests/EntityUpdateUIAccessTest.php
View source
<?php
namespace Drupal\entity_update_tests\Tests;
use Drupal\simpletest\WebTestBase;
class EntityUpdateUIAccessTest extends WebTestBase {
public static $modules = [
'entity_update',
'entity_update_tests',
];
protected function setUp() {
parent::setUp();
$permissions = [
'administer software updates',
];
$this->user = $this
->drupalCreateUser([]);
$this->admin_user = $this
->drupalCreateUser($permissions);
}
public function testAnonymousAccess() {
$this
->runPageAccess(403, 'testAnonymousAccess');
}
public function testSimpleUserAccess() {
$this
->drupalLogin($this->user);
$this
->runPageAccess(403, 'testSimpleUserAccess');
}
public function testAdminsAccess() {
$this
->drupalLogin($this->admin_user);
$this
->runPageAccess(200, 'testAdminsAccess');
}
private function runPageAccess($code = NULL, $method = '') {
if (!$code) {
return;
}
$this
->drupalGet('');
$this
->assertResponse(200, "Home : {$method}");
$this
->drupalGet('admin/config/development/entity-update');
$this
->assertResponse($code, "Page : Root ({$code})");
$this
->drupalGet('admin/config/development/entity-update/tests');
$this
->assertResponse($code, "Page : Test entity fields settings page ({$code})");
$this
->drupalGet('admin/config/development/entity-update/exec');
$this
->assertResponse($code, "Page : Entity update exec page ({$code})");
$this
->drupalGet('admin/config/development/entity-update/types');
$this
->assertResponse($code, "Page : Entity types ({$code})");
$this
->drupalGet('admin/config/development/entity-update/status');
$this
->assertResponse($code, "Page : Entity types update status ({$code})");
$this
->drupalGet('admin/config/development/entity-update/list');
$this
->assertResponse($code, "Page : Entity list ({$code})");
$this
->drupalGet('admin/config/development/entity-update/list/user/1');
$this
->assertResponse($code, "Page : Entity list of user/1 ({$code})");
$this
->drupalGet('admin/config/development/entity-update/list/user/1/2');
$this
->assertResponse($code, "Page : Entity list of user/1/2 ({$code})");
}
}