nd.tools.test in Display Suite 6.3
Tests for Node displays (defaults)
File
modules/nd/tests/nd.tools.testView source
<?php
/**
* @file
* Tests for Node displays (defaults)
*/
class NodeDisplaysDefaults extends DrupalWebTestCase {
/**
* Implementation of getInfo().
*/
function getInfo() {
return array(
'name' => t('ND defaults'),
'description' => t('Tests for default settings.'),
'group' => t('Display suite'),
);
}
/**
* Implementation of setUp().
*/
function setUp() {
parent::setUp('ds', 'ds_ui', 'nd', 'ndtest');
}
/**
* Debug helper function. Writes values away to a text file in the files directory.
*/
function _debugHelper($value, $writetype = 'a+') {
$debug = fopen($this->originalFileDirectory . '/simpletestdebug.txt', 'a+');
fwrite($debug, print_r($value, TRUE) . "\n");
fclose($debug);
}
/**
* Test defaults.
*/
function testDefaults() {
drupal_flush_all_caches();
$admin_user = $this
->drupalCreateUser(array(
'administer nodes',
'access display suite',
'administer nd',
'configure layout for nd',
'export and import settings',
'revert overridden settings',
'use PHP in custom fields',
));
$this
->drupalLogin($admin_user);
// Verify settings are default.
$settings = ds_get_settings('nd', 'page', 'full', 'settings', TRUE);
$this
->assertEqual($settings['status'], DS_SETTINGS_DEFAULT, t('Settings for page full are default'), t('Default settings'));
// Verify that test key is available on page but not on story.
$this
->drupalGet(DS_PATH_LAYOUT . '/page/full');
$this
->assertRaw('edit-test-key-full-label-value', t('Default test key found'), t('Default fields'));
$this
->drupalGet(DS_PATH_LAYOUT . '/story/full');
$this
->assertNoRaw('edit-test-key-full-label-value', t('Default test key not found'), t('Default fields'));
// Verify test key is rendered.
$page_node = $this
->drupalCreateNode();
$this
->drupalGet('node/' . $page_node->nid);
$this
->assertText('Test key: ' . $page_node->nid, t('Test key rendered.'), t('Default fields'));
// Verify that we have overriden settings by disabling test key.
$edit = array(
'author[full][region]' => 'header',
'post_date[full][region]' => 'header',
'body[full][region]' => 'middle',
'test_key[full][region]' => 'disabled',
);
$this
->drupalPost(DS_PATH_LAYOUT . '/page/full', $edit, t('Save'));
$this
->drupalGet('node/' . $page_node->nid);
$this
->assertNoText('Test key: ' . $page_node->nid, t('Test key not rendered.'), t('Default fields'));
// Verify display settings are overriden.
$settings = ds_get_settings('nd', 'page', 'full', 'settings', TRUE);
$this
->assertEqual($settings['status'], DS_SETTINGS_OVERRIDDEN, t('Settings for page full are overriden'), t('Default settings'));
// Verify we can revert to default settings and se test key is rendered again.
$this
->drupalPost(DS_PATH_TOOLS . '/revert/nd/page/full', array(), t('Confirm'));
$this
->drupalGet('node/' . $page_node->nid);
$this
->assertText('Test key: ' . $page_node->nid, t('Test key rendered.'), t('Default fields'));
// Verify settings are default again.
$settings = ds_get_settings('nd', 'page', 'full', 'settings', TRUE);
$this
->assertEqual($settings['status'], DS_SETTINGS_DEFAULT, t('Settings for page full are default'), t('Default settings'));
}
}
Classes
Name | Description |
---|---|
NodeDisplaysDefaults | @file Tests for Node displays (defaults) |