You are here

function OgAccessUseGroupDefaultsTestCase::testCatchException in Organic groups 7.2

Create a group content with group content access field when the group doesn't have an access field, and the "Use group defaults" is selected.

File

og_access/og_access.test, line 389
Test organic groups access module.

Class

OgAccessUseGroupDefaultsTestCase
Test "Use group defaults".

Code

function testCatchException() {
  $settings = array(
    'type' => $this->group_content_type,
  );
  $settings[OG_AUDIENCE_FIELD][LANGUAGE_NONE][0]['target_id'] = $this->group_node->nid;
  $settings[OG_CONTENT_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = OG_CONTENT_ACCESS_DEFAULT;
  try {
    $this
      ->drupalCreateNode($settings);
    $this
      ->fail("Can set node visibility  when access field is missing from the group.");
  } catch (OgException $e) {
    $this
      ->pass("Cannot set node visibility when access field is missing from the group.");
  }

  // Attach the OG access field to the group bundle and try to create a
  // group content.
  og_create_field(OG_ACCESS_FIELD, 'node', $this->group_type);
  $node = $this
    ->drupalCreateNode($settings);
  $this
    ->assertTrue($node, 'A group content has been created successfully.');
}