You are here

function RegistrationStandardTestCase::testRegistrationFieldCreate in Entity Registration 7.2

Same name and namespace in other branches
  1. 8.2 tests/registration.test \RegistrationStandardTestCase::testRegistrationFieldCreate()
  2. 7 tests/registration.test \RegistrationStandardTestCase::testRegistrationFieldCreate()

Tests if registration fields were created successfully, and associated with an entity.

File

tests/registration.test, line 127
Tests for the Registration module

Class

RegistrationStandardTestCase
Creates a registration type Create node entity type ensure registration type exists

Code

function testRegistrationFieldCreate() {
  $field_name =& $this->field['field_name'];
  $entity =& $this->host_entity;

  // Field created.
  $this
    ->assertTrue(isset($this->field['id']), t('Registration field created'), 'Registration');

  // Instance created.
  $read_instance = field_read_instance($this->host_entity_type, $field_name, $entity->type);
  $this
    ->assertNotIdentical(FALSE, $read_instance, t('Create registration instance'), 'Registration');

  // Get Instance.
  $registration_instances = registration_get_registration_instances(array(
    'entity_type' => $this->host_entity_type,
    'bundle' => $entity->type,
  ));
  $this
    ->assertTrue(count($registration_instances) == 1, t('Read registration field instances'), 'Registration');
  $this
    ->assertTrue($registration_instances[0]['field_name'] == $field_name, t('Validate registration field instance data.'), 'Registration');
}