function FieldUIManageDisplayTestCase::assertNodeViewTextHelper

Asserts that a string is (not) found in the rendered nodein a view mode.

This helper function is used by assertNodeViewText() and assertNodeViewNoText().

Parameters

$node: The node.

$view_mode: The view mode in which the node should be displayed.

$text: Plain text to look for.

$message: Message to display.

$not_exists: TRUE if this text should not exist, FALSE if it should.

Return value

TRUE on pass, FALSE on fail.

2 calls to FieldUIManageDisplayTestCase::assertNodeViewTextHelper()
FieldUIManageDisplayTestCase::assertNodeViewNoText in modules/field_ui/field_ui.test
Asserts that a string is not found in the rendered node in a view mode.
FieldUIManageDisplayTestCase::assertNodeViewText in modules/field_ui/field_ui.test
Asserts that a string is found in the rendered node in a view mode.

File

modules/field_ui/field_ui.test, line 662

Class

FieldUIManageDisplayTestCase
Tests the functionality of the 'Manage display' screens.

Code

function assertNodeViewTextHelper($node, $view_mode, $text, $message, $not_exists) {
    // Make sure caches on the tester side are refreshed after changes
    // submitted on the tested side.
    field_info_cache_clear();
    // Save current content so that we can restore it when we're done.
    $old_content = $this->drupalGetContent();
    // Render a cloned node, so that we do not alter the original.
    $clone = clone $node;
    $element = node_view($clone, $view_mode);
    $output = drupal_render($element);
    $this->verbose(t('Rendered node - view mode: @view_mode', array(
        '@view_mode' => $view_mode,
    )) . '<hr />' . $output);
    // Assign content so that DrupalWebTestCase functions can be used.
    $this->drupalSetContent($output);
    $method = $not_exists ? 'assertNoText' : 'assertText';
    $return = $this->{$method}((string) $text, $message);
    // Restore previous content.
    $this->drupalSetContent($old_content);
    return $return;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.