You are here

public function DomainTestTrait::addDomainsToEntity in Domain Access 8

Adds a test domain to an entity.

Parameters

string $entity_type: The entity type being acted upon.

int $entity_id: The entity id.

array|string $ids: An id or array of ids to add.

string $field: The name of the domain field used to attach to the entity.

13 calls to DomainTestTrait::addDomainsToEntity()
DomainAccessElementTest::runInstalledTest in domain_access/tests/src/Functional/DomainAccessElementTest.php
Basic test setup.
DomainAccessFieldTest::testDomainAccessFields in domain_access/tests/src/Functional/DomainAccessFieldTest.php
Tests that the fields are accessed properly.
DomainAccessPermissionsTest::testDomainAccessCreatePermissions in domain_access/tests/src/Functional/DomainAccessPermissionsTest.php
Tests domain access create permissions.
DomainAccessPermissionsTest::testDomainAccessLimitedCreatePermissions in domain_access/tests/src/Functional/DomainAccessPermissionsTest.php
Tests domain access limited create permissions.
DomainAccessPermissionsTest::testDomainAccessPermissions in domain_access/tests/src/Functional/DomainAccessPermissionsTest.php
Runs basic tests for node_access function.

... See full list

File

domain/tests/src/Traits/DomainTestTrait.php, line 93

Class

DomainTestTrait
Contains helper classes for tests to set up various configuration.

Namespace

Drupal\Tests\domain\Traits

Code

public function addDomainsToEntity($entity_type, $entity_id, $ids, $field) {
  if ($entity = \Drupal::entityTypeManager()
    ->getStorage($entity_type)
    ->load($entity_id)) {
    $entity
      ->set($field, $ids);
    $entity
      ->save();
  }
}