You are here

protected function ProfileTestTrait::createProfileType in Profile 8

Creates a profile type for tests.

Parameters

string $id: The profile type machine name.

string $label: The profile type human display name.

bool $registration: Boolean if profile type shows on registration form.

array $roles: Array of user role machine names.

Return value

\Drupal\profile\Entity\ProfileTypeInterface Returns a profile type entity.

3 calls to ProfileTestTrait::createProfileType()
ProfileRoleAccessTest::setUp in tests/src/Kernel/ProfileRoleAccessTest.php
ProfileTestBase::setUp in tests/src/Functional/ProfileTestBase.php
ProfileViewTest::testProfileRelationship in tests/src/Kernel/ProfileViewTest.php
Tests views relationship with multiple referenced entities.

File

src/ProfileTestTrait.php, line 32

Class

ProfileTestTrait
Provides methods to create additional profiles and profile_types.

Namespace

Drupal\profile

Code

protected function createProfileType($id = NULL, $label = NULL, $registration = FALSE, array $roles = []) {
  $id = !empty($id) ? $id : $this
    ->randomMachineName();
  $label = !empty($label) ? $label : $this
    ->randomMachineName();
  $type = ProfileType::create([
    'id' => $id,
    'label' => $label,
    'display_label' => $label,
    'registration' => $registration,
    'roles' => $roles,
  ]);
  $type
    ->save();
  return $type;
}