public function DomainAccessPermissionsTest::testDomainAccessLimitedCreatePermissions in Domain Access 8
Tests domain access limited create permissions.
File
- domain_access/
tests/ src/ Functional/ DomainAccessPermissionsTest.php, line 247  
Class
- DomainAccessPermissionsTest
 - Tests the domain access integration with node_access callbacks.
 
Namespace
Drupal\Tests\domain_access\FunctionalCode
public function testDomainAccessLimitedCreatePermissions() {
  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_account6 = $this
    ->drupalCreateUser([
    'access content',
    'create page content on assigned domains',
  ]);
  $this
    ->addDomainsToEntity('user', $domain_account6
    ->id(), $two, DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD);
  $domain_user6 = $this->userStorage
    ->load($domain_account6
    ->id());
  $assigned = $this->manager
    ->getAccessValues($domain_user6);
  $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_account6);
    $url = $domain
      ->getPath() . 'node/add/page';
    $this
      ->drupalGet($url);
    if ($domain
      ->id() == $two) {
      $this
        ->assertResponse(200);
    }
    else {
      $this
        ->assertResponse(403);
    }
    // The user should not be allowed to create articles.
    $url = $domain
      ->getPath() . 'node/add/article';
    $this
      ->drupalGet($url);
    $this
      ->assertResponse(403);
  }
}