function RegistrationTestCase::setUpEntity in Entity Registration 7.2
Same name and namespace in other branches
- 8.2 tests/registration.test \RegistrationTestCase::setUpEntity()
- 7 tests/registration.test \RegistrationTestCase::setUpEntity()
3 calls to RegistrationTestCase::setUpEntity()
- RegistrationAPITestCase::setUp in tests/
registration.test - Sets up a Drupal site for running functional and integration tests.
- RegistrationStandardTestCase::setUp in tests/
registration.test - Sets up a Drupal site for running functional and integration tests.
- RegistrationWaitlistTestCase::setUp in modules/
registration_waitlist/ registration_waitlist.test - Sets up a Drupal site for running functional and integration tests.
File
- tests/
registration.test, line 9 - Tests for the Registration module
Class
- RegistrationTestCase
- @file Tests for the Registration module
Code
function setUpEntity() {
// Create registration bundle.
$this->registration_type_name = $this
->randomName();
$label = drupal_strtoupper($this->registration_type_name);
$this->registration_type = entity_create('registration_type', array(
'name' => $this->registration_type_name,
'label' => $label,
'registrant_entity_type' => 'user',
'registrant_bundle' => 'user',
'registrant_email_property' => 'mail',
));
entity_save('registration_type', $this->registration_type);
// Field.
$field_name = 'test_registration_field';
$this->field = field_create_field(array(
'field_name' => $field_name,
'type' => 'registration',
));
// Create main entity.
$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);
// Field instance.
$this->field_instance = field_create_instance(array(
'field_name' => $field_name,
'entity_type' => $this->host_entity_type,
'bundle' => $this->host_entity_bundle,
'display' => array(
'default' => array(
'type' => 'registration_form',
),
),
));
// Set registration type for entity.
$this->host_entity->{$field_name}[LANGUAGE_NONE][0]['registration_type'] = $this->registration_type_name;
entity_save($this->host_entity_type, $this->host_entity);
$uri = entity_uri($this->host_entity_type, $this->host_entity);
$this->host_entity_path = $uri['path'];
}