function RegistrationTestCase::setUpEntity in Entity Registration 8.2
Same name in this branch
- 8.2 tests/registration.test \RegistrationTestCase::setUpEntity()
- 8.2 src/RegistrationTestCase.php \Drupal\registration\RegistrationTestCase::setUpEntity()
2 calls to RegistrationTestCase::setUpEntity()
- RegistrationAPITestCase::setUp in src/RegistrationAPITestCase.php
- RegistrationStandardTestCase::setUp in src/RegistrationStandardTestCase.php
File
- src/RegistrationTestCase.php, line 10
- Tests for the Registration module
Class
- RegistrationTestCase
- @file
Tests for the Registration module
Namespace
Drupal\registration
Code
function setUpEntity() {
$this->registration_type_name = $this
->randomName();
$label = \Drupal\Component\Utility\Unicode::strtoupper($this->registration_type_name);
$this->registration_type = \Drupal::entityManager()
->getStorage('registration_type')
->create(array(
'name' => $this->registration_type_name,
'label' => $label,
'registrant_entity_type' => 'user',
'registrant_bundle' => 'user',
'registrant_email_property' => 'mail',
));
$this->registration_type
->save();
$field_name = 'test_registration_field';
$this->host_entity_type = 'node';
$this->host_entity = $this
->drupalCreateNode();
list($this->host_entity_id, , $this->host_entity_bundle) = entity_extract_ids($this->host_entity_type, $this->host_entity);
$this->host_entity->{$field_name}[\Drupal\Core\Language\Language::LANGCODE_NOT_SPECIFIED][0]['registration_type'] = $this->registration_type_name;
$this->host_entity
->save();
$uri = entity_uri($this->host_entity_type, $this->host_entity);
$this->host_entity_path = $uri['path'];
}