You are here

function ProfileAttachTest::setUp in Profile 2 8

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides WebTestBase::setUp

File

src/Tests/ProfileAttachTest.php, line 23
Contains \Drupal\profile\Tests\ProfileAttachTest.

Class

ProfileAttachTest
Tests attaching of profile entity forms to other forms.

Namespace

Drupal\profile\Tests

Code

function setUp() {
  parent::setUp();
  $this->type = entity_create('profile_type', array(
    'id' => 'test',
    'label' => 'Test profile',
    'weight' => 0,
    'registration' => TRUE,
  ));
  $this->type
    ->save();
  $this->field = array(
    'field_name' => 'profile_fullname',
    'type' => 'text',
    'entity_type' => 'profile',
    'cardinality' => 1,
    'translatable' => FALSE,
  );
  $this->field = FieldStorageConfig::create($this->field);
  $this->field
    ->save();
  $this->instance = array(
    'entity_type' => $this->field->entity_type,
    'field_name' => $this->field->field_name,
    'bundle' => $this->type
      ->id(),
    'label' => 'Full name',
    'required' => TRUE,
    'widget' => array(
      'type' => 'text_textfield',
    ),
  );
  $this->instance = FieldConfig::create($this->instance);
  $this->instance
    ->save();
  $this->display = entity_get_display('profile', 'test', 'default')
    ->setComponent($this->field->field_name, array(
    'type' => 'text_default',
  ));
  $this->display
    ->save();
  $this->form = entity_get_form_display('profile', 'test', 'default')
    ->setComponent($this->field->field_name, array(
    'type' => 'string_textfield',
  ));
  $this->form
    ->save();
  $this
    ->checkPermissions(array(), TRUE);
}