You are here

class PartyBaseTestCase in Party 8.2

Same name and namespace in other branches
  1. 7 tests/party.test \PartyBaseTestCase

Base class for all Party tests.

Hierarchy

Expanded class hierarchy of PartyBaseTestCase

File

tests/party.test, line 11
Tests for the Party module.

View source
class PartyBaseTestCase extends DrupalWebTestCase {

  /**
   * Create a test profile2 type and return the profile2 type machine name.
   */
  public function createTestProfile2() {
    $label = 'Party Test Profile2';
    $machine_name = 'party_test_profile2';
    $profile_type = new ProfileType(array(
      'type' => $machine_name,
      'label' => $label,
      'weight' => 0,
    ));
    profile2_type_save($profile_type);

    // Clear Profile2 cache.
    profile2_load_multiple(FALSE, array(), TRUE);

    // Clear the Data Set cache.
    $this
      ->assertNotNull(party_get_data_set_info(NULL, TRUE), "Data Set has been created for profile2 type {$label}");

    // Add a field to Party Test type.
    $field = array(
      'field_name' => 'party_test_field',
      'type' => 'text',
      'cardinality' => 1,
      'translatable' => FALSE,
    );
    field_create_field($field);
    $instance = array(
      'entity_type' => 'profile2',
      'field_name' => 'party_test_field',
      'bundle' => $machine_name,
      'label' => 'Party Test Field',
      'description' => 'Party Test Field - Text type.',
      'widget' => array(
        'type' => 'text_textfield',
        'weight' => 0,
      ),
    );
    field_create_instance($instance);

    // Clear all caches
    drupal_flush_all_caches();

    // @todo: Check permission have been created for the new data set.
    $this
      ->checkPermissions(array(
      'attach party profile2_' . $machine_name,
    ), TRUE);
    return $machine_name;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PartyBaseTestCase::createTestProfile2 public function Create a test profile2 type and return the profile2 type machine name.