StatisticsReportsTestCase::testPopularContentBlock

7 statistics.test StatisticsReportsTestCase::testPopularContentBlock()
8 statistics.test StatisticsReportsTestCase::testPopularContentBlock()

Tests the "popular content" block.

File

modules/statistics/statistics.test, line 206
Tests for statistics.module.

Code

function testPopularContentBlock() {
  // Visit a node to have something show up in the block.
  $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->blocking_user->uid));
  $this->drupalGet('node/' . $node->nid);

  // Configure and save the block.
  $block = block_load('statistics', 'popular');
  $block->theme = variable_get('theme_default', 'bartik');
  $block->status = 1;
  $block->pages = '';
  $block->region = 'sidebar_first';
  $block->cache = -1;
  $block->visibility = 0;
  $edit = array(
    'statistics_block_top_day_num' => 3,
    'statistics_block_top_all_num' => 3,
    'statistics_block_top_last_num' => 3,
  );
  module_invoke('statistics', 'block_save', 'popular', $edit);
  drupal_write_record('block', $block);

  // Get some page and check if the block is displayed.
  $this->drupalGet('user');
  $this->assertText('Popular content', t('Found the popular content block.'));
  $this->assertText("Today's", t('Found today\'s popular content.'));
  $this->assertText('All time', t('Found the alll time popular content.'));
  $this->assertText('Last viewed', t('Found the last viewed popular content.'));

  $this->assertRaw(l($node->title, 'node/' . $node->nid), t('Found link to visited node.'));
}
Login or register to post comments