You are here

function dsHooksTests::testDSFields in Display Suite 7.2

Same name and namespace in other branches
  1. 7 tests/ds.base.test \dsHooksTests::testDSFields()

Test fields hooks.

File

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

Class

dsHooksTests
Tests for Display Suite hooks.

Code

function testDSFields() {
  $this
    ->dsSelectLayout();

  // Find the two extra fields from the test module on the node type.
  $this
    ->drupalGet('admin/structure/types/manage/article/display');
  $this
    ->assertText('Test code field from hook', 'Test field found on node.');
  $this
    ->assertText('Field altered', 'Test field altered found on node.');
  $empty = array();
  $edit = array(
    'additional_settings[layout]' => 'ds_2col_stacked',
  );
  $this
    ->dsSelectLayout($edit, $empty, 'admin/config/people/accounts/display');

  // Fields can not be found on user.
  $this
    ->drupalGet('admin/config/people/accounts/display');
  $this
    ->assertNoText('Test code field from hook', 'Test field not found on user.');
  $this
    ->assertNoText('Field altered', 'Test field altered not found on user.');

  // Select layout.
  $this
    ->dsSelectLayout();
  $fields = array(
    'fields[author][region]' => 'left',
    'fields[links][region]' => 'left',
    'fields[body][region]' => 'right',
    'fields[ds_test_field][region]' => 'right',
    'fields[ds_test_field_empty_string][region]' => 'right',
    'fields[ds_test_field_empty_string][label]' => 'inline',
    'fields[ds_test_field_false][region]' => 'right',
    'fields[ds_test_field_false][label]' => 'inline',
    'fields[ds_test_field_null][region]' => 'right',
    'fields[ds_test_field_null][label]' => 'inline',
    'fields[ds_test_field_nothing][region]' => 'right',
    'fields[ds_test_field_nothing][label]' => 'inline',
    'fields[ds_test_field_zero_int][region]' => 'right',
    'fields[ds_test_field_zero_int][label]' => 'inline',
    'fields[ds_test_field_zero_string][region]' => 'right',
    'fields[ds_test_field_zero_string][label]' => 'inline',
    'fields[ds_test_field_zero_float][region]' => 'right',
    'fields[ds_test_field_zero_float][label]' => 'inline',
  );
  $this
    ->dsSelectLayout();
  $this
    ->dsConfigureUI($fields);

  // Create a node.
  $settings = array(
    'type' => 'article',
  );
  $node = $this
    ->drupalCreateNode($settings);
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertRaw('group-left', 'Template found (region left)');
  $this
    ->assertRaw('group-right', 'Template found (region right)');
  $this
    ->assertText('Test code field on node ' . $node->nid, 'Test code field found');
  $this
    ->assertNoText('Test code field that returns an empty string', 'Test code field that returns an empty string is not visible.');
  $this
    ->assertNoText('Test code field that returns FALSE', 'Test code field that returns FALSE is not visible.');
  $this
    ->assertNoText('Test code field that returns NULL', 'Test code field that returns NULL is not visible.');
  $this
    ->assertNoText('Test code field that returns nothing', 'Test code field that returns nothing is not visible.');
  $this
    ->assertNoText('Test code field that returns an empty array', 'Test code field that returns an empty array is not visible.');
  $this
    ->assertText('Test code field that returns zero as an integer', 'Test code field that returns zero as an integer is visible.');
  $this
    ->assertText('Test code field that returns zero as a string', 'Test code field that returns zero as a string is visible.');
  $this
    ->assertText('Test code field that returns zero as a floating point number', 'Test code field that returns zero as a floating point number is visible.');
}