function DrupalRenderTestCase::testDrupalRenderBasics

Tests the output drupal_render() for some elementary input values.

File

modules/simpletest/tests/common.test, line 2082

Class

DrupalRenderTestCase
Tests for drupal_render().

Code

function testDrupalRenderBasics() {
    $types = array(
        array(
            'name' => 'null',
            'value' => NULL,
            'expected' => '',
        ),
        array(
            'name' => 'no value',
            'expected' => '',
        ),
        array(
            'name' => 'empty string',
            'value' => '',
            'expected' => '',
        ),
        array(
            'name' => 'not a render array',
            'value' => 'this is not an array',
            'expected' => '',
        ),
        array(
            'name' => 'no access',
            'value' => array(
                '#markup' => 'foo',
                '#access' => FALSE,
            ),
            'expected' => '',
        ),
        array(
            'name' => 'previously printed',
            'value' => array(
                '#markup' => 'foo',
                '#printed' => TRUE,
            ),
            'expected' => '',
        ),
        array(
            'name' => 'printed in prerender',
            'value' => array(
                '#markup' => 'foo',
                '#pre_render' => array(
                    'common_test_drupal_render_printing_pre_render',
                ),
            ),
            'expected' => '',
        ),
        array(
            'name' => 'basic renderable array',
            'value' => array(
                '#markup' => 'foo',
            ),
            'expected' => 'foo',
        ),
    );
    foreach ($types as $type) {
        $this->assertIdentical(drupal_render($type['value']), $type['expected'], '"' . $type['name'] . '" input rendered correctly by drupal_render().');
    }
}

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