public function DomainAccessPermissionsTest::testDomainAccessCreatePermissions in Domain Access 8
Tests domain access create permissions.
File
- domain_access/
tests/ src/ Functional/ DomainAccessPermissionsTest.php, line 203
Class
- DomainAccessPermissionsTest
- Tests the domain access integration with node_access callbacks.
Namespace
Drupal\Tests\domain_access\FunctionalCode
public function testDomainAccessCreatePermissions() {
foreach ($this->domains as $domain) {
if (!isset($one)) {
$one = $domain
->id();
continue;
}
if (!isset($two)) {
$two = $domain
->id();
}
}
// Tests create permissions. Any content on assigned domains.
$domain_account5 = $this
->drupalCreateUser([
'access content',
'create domain content',
]);
$this
->addDomainsToEntity('user', $domain_account5
->id(), $two, DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD);
$domain_user5 = $this->userStorage
->load($domain_account5
->id());
$assigned = $this->manager
->getAccessValues($domain_user5);
$this
->assertCount(1, $assigned, 'User assigned to one domain.');
$this
->assertArrayHasKey($two, $assigned, 'User assigned to proper test domain.');
// This test is domain sensitive.
foreach ($this->domains as $domain) {
$this
->domainLogin($domain, $domain_account5);
$url = $domain
->getPath() . 'node/add/page';
$this
->drupalGet($url);
if ($domain
->id() == $two) {
$this
->assertResponse(200);
}
else {
$this
->assertResponse(403);
}
// The user should be allowed to create articles.
$url = $domain
->getPath() . 'node/add/article';
$this
->drupalGet($url);
if ($domain
->id() == $two) {
$this
->assertResponse(200);
}
else {
$this
->assertResponse(403);
}
}
}