You are here

function OgFieldWidgetTestCase::testMultipleFields in Organic groups 7.2

Test multiple group-audience fields.

File

./og.test, line 1233

Class

OgFieldWidgetTestCase
Test the complex widget.

Code

function testMultipleFields() {

  // Add another group-audience field.
  $og_field = og_fields_info(OG_AUDIENCE_FIELD);
  og_create_field('another_field', 'node', 'post', $og_field);
  $user1 = $this
    ->drupalCreateUser();

  // Create a group.
  $settings = array(
    'type' => 'group',
    OG_GROUP_FIELD . '[und][0][value]' => 1,
    'uid' => $user1->uid,
  );
  $group1 = $this
    ->drupalCreateNode($settings);
  $group2 = $this
    ->drupalCreateNode($settings);

  // Create group content.
  $settings = array(
    'type' => 'post',
    'uid' => $user1->uid,
  );
  $post1 = $this
    ->drupalCreateNode($settings);
  og_group('node', $group1->nid, array(
    'entity_type' => 'node',
    'entity' => $post1,
    'field_name' => OG_AUDIENCE_FIELD,
  ));
  og_group('node', $group2->nid, array(
    'entity_type' => 'node',
    'entity' => $post1,
    'field_name' => 'another_field',
  ));
  $this
    ->drupalLogin($user1);
  $this
    ->drupalGet("node/{$post1->nid}/edit");

  // Assert correct selection in both fields.
  $this
    ->assertOptionSelected('edit-og-group-ref-und-0-default', $group1->nid);
  $this
    ->assertOptionSelected('edit-another-field-und-0-default', $group2->nid);
}