diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-02-09 03:29:54 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-02-09 03:29:54 +0000 |
commit | c591f4562df55d7c656e201b17c6ce6f84d22926 (patch) | |
tree | 5bdbbe4aa13e1599be6045ee9d05d63153821379 /modules | |
parent | 341a95b80353ce93c62050c3051c6402063da5dc (diff) | |
download | brdo-c591f4562df55d7c656e201b17c6ce6f84d22926.tar.gz brdo-c591f4562df55d7c656e201b17c6ce6f84d22926.tar.bz2 |
#370846 by catch: Further improve performance of drupal_render() sorting (with tests).
Diffstat (limited to 'modules')
-rw-r--r-- | modules/simpletest/tests/common.test | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index a6f1053e6..9d8c1d23f 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -535,8 +535,29 @@ class DrupalRenderUnitTestCase extends DrupalWebTestCase { ), ); $output = drupal_render($elements); + // The lowest weight element should appear last in $output. - $this->assertTrue(strpos($output, $second) > strpos($output, $first), t('Elements were sorted correctly by weight')); + $this->assertTrue(strpos($output, $second) > strpos($output, $first), t('Elements were sorted correctly by weight.')); + + // Confirm that the $elements array has '#sorted' set to TRUE. + $this->assertTrue($elements['#sorted'], t("'#sorted' => TRUE was added to the array")); + + // Now the same array structure, but with #sorted set to TRUE. + $elements = array( + 'second' => array( + '#weight' => 10, + '#markup' => $second, + ), + 'first' => array( + '#weight' => 0, + '#markup' => $first, + ), + '#sorted' => TRUE, + ); + $output = drupal_render($elements); + + // The elements should appear in output in the same order as the array. + $this->assertTrue(strpos($output, $second) < strpos($output, $first), t('Elements were not sorted.')); } } |