You are here

public function DomainTestTrait::domainPostValues in Domain Access 8

Creates domain record for use with POST request tests.

3 calls to DomainTestTrait::domainPostValues()
DomainCheckResponseTest::testDomainCheckResponse in domain/tests/src/Functional/DomainCheckResponseTest.php
Tests that a domain responds as expected.
DomainEntityAccessTest::testDomainCreate in domain/tests/src/Functional/DomainEntityAccessTest.php
Tests initial domain creation.
DomainFormsTest::testDomainInterface in domain/tests/src/Functional/DomainFormsTest.php
Create, edit and delete a domain via the user interface.

File

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

Class

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

Namespace

Drupal\Tests\domain\Traits

Code

public function domainPostValues() {
  $edit = [];
  $domain = \Drupal::entityTypeManager()
    ->getStorage('domain')
    ->create();
  $required = \Drupal::service('domain.validator')
    ->getRequiredFields();
  foreach ($required as $key) {
    $edit[$key] = $domain
      ->get($key);
  }

  // URL validation has issues on Travis, so only do it when requested.
  $edit['validate_url'] = 0;
  $edit['id'] = \Drupal::entityTypeManager()
    ->getStorage('domain')
    ->createMachineName($edit['hostname']);
  return $edit;
}