function dsNodeTests::entitiesTestSetup in Display Suite 7
Same name and namespace in other branches
- 7.2 tests/ds.entities.test \dsNodeTests::entitiesTestSetup()
Utility function to setup for all kinds of tests.
Parameters
$label: How the body label must be set.
2 calls to dsNodeTests::entitiesTestSetup()
- dsNodeTests::testDSFieldTemplate in tests/
ds.entities.test - Tests on field templates.
- dsNodeTests::testDSNodeEntity in tests/
ds.entities.test - Test basic node display fields.
File
- tests/
ds.entities.test, line 27 - Entities tests
Class
- dsNodeTests
- @file Entities tests
Code
function entitiesTestSetup($label = 'above') {
// Create a node.
$settings = array(
'type' => 'article',
'promote' => 1,
);
$node = $this
->drupalCreateNode($settings);
// Create field styles.
$edit = array(
'ds_styles_fields' => "test_field_class\ntest_field_class_2|Field class 2",
);
$this
->drupalPost('admin/structure/ds/styles', $edit, t('Save configuration'));
// Create a token and php field.
$token_field = array(
'name' => 'Token field',
'field' => 'token_field',
'entities[node]' => '1',
'code[value]' => '<div class="token-class">[node:title]</span>',
'use_token' => '1',
);
$php_field = array(
'name' => 'PHP field',
'field' => 'php_field',
'entities[node]' => '1',
'code[value]' => "<?php echo 'I am a PHP field'; ?>",
'use_token' => '0',
);
$this
->dsCreateCodeField($token_field);
$this
->dsCreateCodeField($php_field);
// Select layout.
$this
->dsSelectLayout();
// Configure fields.
$fields = array(
'fields[token_field][region]' => 'header',
'fields[php_field][region]' => 'left',
'fields[body][region]' => 'right',
'fields[links][region]' => 'footer',
'fields[body][label]' => $label,
);
$this
->dsConfigureUI($fields);
return $node;
}