function FlagCommentOptimizationTestCase::testCommentView in Flag 7.3
Test viewing multiple comments on a node is optimized.
File
- tests/
flag.test, line 1765 - Tests for the Flag module.
Class
- FlagCommentOptimizationTestCase
- Verifies the optimization for comment viewing.
Code
function testCommentView() {
// View the node.
$this
->drupalGet('node/' . $this->nid);
// Inspect the tracking variable.
// Hooks in the flag_comment_flag_test module will have populated this with
// data at various points in the lifecycle of the loaded page.
$tracking_variable = variable_get('flag_comment_flag_test_user_flags_cache_tracking', array());
$this
->assertNull($tracking_variable['hook_comment_load'], "The flag_get_user_flags() static cache is empty when the comments are being loaded.");
// The test module's hook_entity_view() runs after flag's implementation, so
// for the first comment view, the cache should be fully populated: all
// comments should have an entry.
foreach ($this->cids as $cid) {
$this
->assertNotNull($tracking_variable['hook_entity_view_1'][$this->user->uid][0]['comment'][$cid], "The static cache contained data for comment {$cid} when comment 1 was being viewed.");
}
}