Issue #1797520 by Lars Toomre: Remove t() from test assertions in statistics module

8.0.x
Jennifer Hodgdon 2012-10-01 13:24:55 -07:00
parent 31f0b95cbf
commit c259b8ec52
4 changed files with 38 additions and 38 deletions

View File

@ -62,19 +62,19 @@ class StatisticsAdminTest extends WebTestBase {
*/
function testStatisticsSettings() {
$config = config('statistics.settings');
$this->assertFalse($config->get('access_log.enabled'), t('Access log is disabled by default.'));
$this->assertFalse($config->get('count_content_views'), t('Count content view log is disabled by default.'));
$this->assertFalse($config->get('access_log.enabled'), 'Access log is disabled by default.');
$this->assertFalse($config->get('count_content_views'), 'Count content view log is disabled by default.');
$this->drupalGet('admin/reports/pages');
$this->assertRaw(t('No statistics available.'), t('Verifying text shown when no statistics is available.'));
$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'));
$config = config('statistics.settings');
$this->assertTrue($config->get('access_log.enabled'), t('Access log is enabled.'));
$this->assertTrue($config->get('count_content_views'), t('Count content view log is enabled.'));
$this->assertTrue($config->get('access_log.enabled'), 'Access log is enabled.');
$this->assertTrue($config->get('count_content_views'), 'Count content view log is enabled.');
// Hit the node.
$this->drupalGet('node/' . $this->test_node->nid);
@ -87,17 +87,17 @@ class StatisticsAdminTest extends WebTestBase {
drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
$this->drupalGet('admin/reports/pages');
$this->assertText('node/1', t('Test node found.'));
$this->assertText('node/1', 'Test node found.');
// Hit the node again (the counter is incremented after the hit, so
// "1 view" will actually be shown when the node is hit the second time).
$this->drupalGet('node/' . $this->test_node->nid);
drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
$this->assertText('1 view', t('Node is viewed once.'));
$this->assertText('1 view', 'Node is viewed once.');
$this->drupalGet('node/' . $this->test_node->nid);
drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
$this->assertText('2 views', t('Node is viewed 2 times.'));
$this->assertText('2 views', 'Node is viewed 2 times.');
}
/**
@ -157,10 +157,10 @@ class StatisticsAdminTest extends WebTestBase {
preg_match('@http.+?(user/\d+/cancel/confirm/\d+/[^\s]+)@', $mail['body'], $matches);
$path = $matches[1];
$this->drupalGet($path);
$this->assertFalse(user_load($account->uid, TRUE), t('User is not found in the database.'));
$this->assertFalse(user_load($account->uid, TRUE), 'User is not found in the database.');
$this->drupalGet('admin/reports/visitors');
$this->assertNoText($account->name, t('Did not find user in visitor statistics.'));
$this->assertNoText($account->name, 'Did not find user in visitor statistics.');
}
/**
@ -184,10 +184,10 @@ class StatisticsAdminTest extends WebTestBase {
drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
$this->drupalGet('node/' . $this->test_node->nid);
drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
$this->assertText('1 view', t('Node is viewed once.'));
$this->assertText('1 view', 'Node is viewed once.');
$this->drupalGet('admin/reports/pages');
$this->assertText('node/' . $this->test_node->nid, t('Hit URL found.'));
$this->assertText('node/' . $this->test_node->nid, 'Hit URL found.');
// statistics_cron() will subtract
// statistics.settings:accesslog.max_lifetime config from REQUEST_TIME in
@ -197,13 +197,13 @@ class StatisticsAdminTest extends WebTestBase {
$this->cronRun();
$this->drupalGet('admin/reports/pages');
$this->assertNoText('node/' . $this->test_node->nid, t('No hit URL found.'));
$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, t('Daycounter is zero.'));
$this->assertFalse($result, 'Daycounter is zero.');
}
}

View File

@ -81,9 +81,9 @@ class StatisticsLoggingTest extends WebTestBase {
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));
$this->assertIdentical($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', t('Testing an uncached page.'));
$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, t('Page request was logged.'));
$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');
@ -92,9 +92,9 @@ class StatisticsLoggingTest extends WebTestBase {
$this->drupalGet($path);
// Manually calling statistics.php, simulating ajax behavior.
drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
$this->assertIdentical($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Testing a cached page.'));
$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, t('Page request was logged.'));
$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');
@ -106,7 +106,7 @@ class StatisticsLoggingTest extends WebTestBase {
drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
$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, t('Page request was 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');
@ -119,7 +119,7 @@ class StatisticsLoggingTest extends WebTestBase {
);
$this->drupalGet($path);
$log = db_query('SELECT * FROM {accesslog}')->fetchAll(PDO::FETCH_ASSOC);
$this->assertTrue(is_array($log) && count($log) == 7, t('Page request was logged.'));
$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

View File

@ -24,9 +24,9 @@ class StatisticsReportsTest extends StatisticsTestBase {
*/
function testRecentHits() {
$this->drupalGet('admin/reports/hits');
$this->assertText('test', t('Hit title found.'));
$this->assertText('node/1', t('Hit URL found.'));
$this->assertText('Anonymous', t('Hit user found.'));
$this->assertText('test', 'Hit title found.');
$this->assertText('node/1', 'Hit URL found.');
$this->assertText('Anonymous', 'Hit user found.');
}
/**
@ -34,8 +34,8 @@ class StatisticsReportsTest extends StatisticsTestBase {
*/
function testTopPages() {
$this->drupalGet('admin/reports/pages');
$this->assertText('test', t('Hit title found.'));
$this->assertText('node/1', t('Hit URL found.'));
$this->assertText('test', 'Hit title found.');
$this->assertText('node/1', 'Hit URL found.');
}
/**
@ -43,7 +43,7 @@ class StatisticsReportsTest extends StatisticsTestBase {
*/
function testTopReferrers() {
$this->drupalGet('admin/reports/referrers');
$this->assertText('http://example.com', t('Hit referrer found.'));
$this->assertText('http://example.com', 'Hit referrer found.');
}
/**
@ -51,9 +51,9 @@ class StatisticsReportsTest extends StatisticsTestBase {
*/
function testDetails() {
$this->drupalGet('admin/reports/access/1');
$this->assertText('test', t('Hit title found.'));
$this->assertText('node/1', t('Hit URL found.'));
$this->assertText('Anonymous', t('Hit user found.'));
$this->assertText('test', 'Hit title found.');
$this->assertText('node/1', 'Hit URL found.');
$this->assertText('Anonymous', 'Hit user found.');
}
/**
@ -62,8 +62,8 @@ class StatisticsReportsTest extends StatisticsTestBase {
function testAccessLogging() {
$this->drupalGet('admin/reports/referrers');
$this->drupalGet('admin/reports/hits');
$this->assertText('Top referrers in the past 3 days', t('Hit title found.'));
$this->assertText('admin/reports/referrers', t('Hit URL found.'));
$this->assertText('Top referrers in the past 3 days', 'Hit title found.');
$this->assertText('admin/reports/referrers', 'Hit URL found.');
}
/**
@ -95,11 +95,11 @@ class StatisticsReportsTest extends StatisticsTestBase {
// 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->assertText('Popular content', 'Found the popular content block.');
$this->assertText("Today's", "Found today's popular content.");
$this->assertText('All time', 'Found the all time popular content.');
$this->assertText('Last viewed', 'Found the last viewed popular content.');
$this->assertRaw(l($node->label(), 'node/' . $node->nid), t('Found link to visited node.'));
$this->assertRaw(l($node->label(), 'node/' . $node->nid), 'Found link to visited node.');
}
}

View File

@ -49,11 +49,11 @@ class StatisticsTokenReplaceTest extends StatisticsTestBase {
$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)), t('No empty tokens generated.'));
$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('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Statistics token %token replaced.', array('%token' => $input)));
$this->assertEqual($output, $expected, format_string('Statistics token %token replaced.', array('%token' => $input)));
}
}
}