From ab21e07bbd3ac303495a9cce99862d84bba0893e Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Sun, 14 Nov 2010 21:04:45 +0000 Subject: #878092 follow-up by sun, David_Rothstein: Fixed Regression from D7 alpha: themes are unable to render one group of node links separately from another. --- modules/simpletest/tests/theme.test | 111 ++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) (limited to 'modules/simpletest') diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test index c2c9e044a..d7d734bb2 100644 --- a/modules/simpletest/tests/theme.test +++ b/modules/simpletest/tests/theme.test @@ -187,6 +187,117 @@ class ThemeItemListUnitTest extends DrupalWebTestCase { } } +/** + * Unit tests for theme_links(). + */ +class ThemeLinksUnitTest extends DrupalUnitTestCase { + public static function getInfo() { + return array( + 'name' => 'Links', + 'description' => 'Test the theme_links() function and rendering groups of links.', + 'group' => 'Theme', + ); + } + + /** + * Test the use of drupal_pre_render_links() on a nested array of links. + */ + function testDrupalPreRenderLinks() { + // Define the base array to be rendered, containing a variety of different + // kinds of links. + $base_array = array( + '#theme' => 'links', + '#pre_render' => array('drupal_pre_render_links'), + '#links' => array( + 'parent_link' => array( + 'title' => 'Parent link original', + 'href' => 'parent-link-original', + ), + ), + 'first_child' => array( + '#theme' => 'links', + '#links' => array( + // This should be rendered if 'first_child' is rendered separately, + // but ignored if the parent is being rendered (since it duplicates + // one of the parent's links). + 'parent_link' => array( + 'title' => 'Parent link copy', + 'href' => 'parent-link-copy', + ), + // This should always be rendered. + 'first_child_link' => array( + 'title' => 'First child link', + 'href' => 'first-child-link', + ), + ), + ), + // This should always be rendered as part of the parent. + 'second_child' => array( + '#theme' => 'links', + '#links' => array( + 'second_child_link' => array( + 'title' => 'Second child link', + 'href' => 'second-child-link', + ), + ), + ), + // This should never be rendered, since the user does not have access to + // it. + 'third_child' => array( + '#theme' => 'links', + '#links' => array( + 'third_child_link' => array( + 'title' => 'Third child link', + 'href' => 'third-child-link', + ), + ), + '#access' => FALSE, + ), + ); + + // Start with a fresh copy of the base array, and try rendering the entire + // thing. We expect a single