function ViewsContentCacheTest::testStoryContentAdded in Views content cache 6.2
Test that when a node is added the appropriate cache segment is updated.
File
- tests/
views_content_cache.test, line 16
Class
Code
function testStoryContentAdded() {
$cid = array(
'node' => array(
'story',
),
);
//$this->verbose(views_content_cache_update_get($cid));
$this
->assertFalse(views_content_cache_update_get($cid, TRUE), t('Ensure that the no timestamp has been set against the story cache segment.'));
$timestamp_before = time();
sleep(1);
$this->node = $this
->drupalCreateNode(array(
'type' => 'story',
));
sleep(1);
$timestamp_after = time();
// Now need to make sure that views content cache recorded the correct time:
$cid = array(
'node' => array(
'story',
),
'node_only' => array(
'node_changed',
),
);
$updated = views_content_cache_update_get($cid, TRUE);
$result = $updated < $timestamp_after && $updated > $timestamp_before;
$this
->assertTrue($result, t('Ensure that the timestamp against the story cache segment is updated.'));
$timestamp_before = time();
sleep(1);
$this->node = $this
->drupalCreateNode(array(
'type' => 'story',
));
sleep(1);
$timestamp_after = time();
// Now need to make sure that views content cache recorded the correct time:
$cid = array(
'node' => array(
'story',
),
'node_only' => array(
'node_changed',
),
);
$updated = views_content_cache_update_get($cid, TRUE);
$result = $updated < $timestamp_after && $updated > $timestamp_before;
$this
->assertTrue($result, t('Ensure that the timestamp against the story cache segment is updated.'));
// Make sure the page segment was untouched:
$this
->assertFalse(views_content_cache_update_get(array(
'node' => array(
'page',
),
), TRUE), t('Ensure that the no timestamp has been set against the page cache segment.'));
}