You are here

function dsFieldPermissionTests::testFieldPermissions in Display Suite 7.2

File

tests/ds.base.test, line 711
Base functions and tests for Display Suite.

Class

dsFieldPermissionTests
Tests for Display Suite field permissions.

Code

function testFieldPermissions() {
  $fields = array(
    'fields[body][region]' => 'right',
    'fields[ds_test_field][region]' => 'left',
  );
  variable_set('ds_extras_field_permissions', TRUE);
  $this
    ->refreshVariables();
  module_implements(FALSE, FALSE, TRUE);
  $this
    ->dsSelectLayout();
  $this
    ->dsConfigureUI($fields);

  // Create a node.
  $settings = array(
    'type' => 'article',
  );
  $node = $this
    ->drupalCreateNode($settings);
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertRaw('group-right', 'Template found (region right)');
  $this
    ->assertNoText('Test code field on node ' . $node->nid, 'Test code field not found');

  // Give permissions.
  $edit = array(
    '2[view author on node]' => 1,
    '2[view ds_test_field on node]' => 1,
  );
  $this
    ->drupalPost('admin/people/permissions', $edit, t('Save permissions'));
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertRaw('group-left', 'Template found (region left)');
  $this
    ->assertText('Test code field on node ' . $node->nid, 'Test code field found');
}