Révision b0dc3a2e
Ajouté par Julien Enselme il y a plus de 7 ans
drupal7/modules/dblog/dblog.test | ||
---|---|---|
119 | 119 |
private function generateLogEntries($count, $type = 'custom', $severity = WATCHDOG_NOTICE) { |
120 | 120 |
global $base_root; |
121 | 121 |
|
122 |
// Make it just a little bit harder to pass the link part of the test. |
|
122 |
// This long URL makes it just a little bit harder to pass the link part of |
|
123 |
// the test with a mix of English words and a repeating series of random |
|
124 |
// percent-encoded Chinese characters. |
|
123 | 125 |
$link = urldecode('/content/xo%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E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9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A-lake-isabelle'); |
124 | 126 |
|
125 | 127 |
// Prepare the fields to be logged |
... | ... | |
518 | 520 |
$this->assertText(t('Database log cleared.'), 'Confirmation message found'); |
519 | 521 |
} |
520 | 522 |
|
523 |
/** |
|
524 |
* Verifies that exceptions are caught in dblog_watchdog(). |
|
525 |
*/ |
|
526 |
protected function testDBLogException() { |
|
527 |
$log = array( |
|
528 |
'type' => 'custom', |
|
529 |
'message' => 'Log entry added to test watchdog handling of Exceptions.', |
|
530 |
'variables' => array(), |
|
531 |
'severity' => WATCHDOG_NOTICE, |
|
532 |
'link' => NULL, |
|
533 |
'user' => $this->big_user, |
|
534 |
'uid' => isset($this->big_user->uid) ? $this->big_user->uid : 0, |
|
535 |
'request_uri' => request_uri(), |
|
536 |
'referer' => $_SERVER['HTTP_REFERER'], |
|
537 |
'ip' => ip_address(), |
|
538 |
'timestamp' => REQUEST_TIME, |
|
539 |
); |
|
540 |
|
|
541 |
// Remove watchdog table temporarily to simulate it missing during |
|
542 |
// installation. |
|
543 |
db_query("DROP TABLE {watchdog}"); |
|
544 |
|
|
545 |
// Add a watchdog entry. |
|
546 |
// This should not throw an Exception, but fail silently. |
|
547 |
dblog_watchdog($log); |
|
548 |
} |
|
549 |
|
|
521 | 550 |
/** |
522 | 551 |
* Gets the database log event information from the browser page. |
523 | 552 |
* |
... | ... | |
636 | 665 |
// Document Object Model (DOM). |
637 | 666 |
$this->assertLink(html_entity_decode($message_text), 0, $message); |
638 | 667 |
} |
668 |
|
|
669 |
/** |
|
670 |
* Make sure HTML tags are filtered out in the log detail page. |
|
671 |
*/ |
|
672 |
public function testLogMessageSanitized() { |
|
673 |
$this->drupalLogin($this->big_user); |
|
674 |
|
|
675 |
// Make sure dangerous HTML tags are filtered out in log detail page. |
|
676 |
$log = array( |
|
677 |
'uid' => 0, |
|
678 |
'type' => 'custom', |
|
679 |
'message' => "<script>alert('foo');</script> <strong>Lorem ipsum</strong>", |
|
680 |
'variables' => NULL, |
|
681 |
'severity' => WATCHDOG_NOTICE, |
|
682 |
'link' => 'foo/bar', |
|
683 |
'request_uri' => 'http://example.com?dblog=1', |
|
684 |
'referer' => 'http://example.org?dblog=2', |
|
685 |
'ip' => '0.0.1.0', |
|
686 |
'timestamp' => REQUEST_TIME, |
|
687 |
); |
|
688 |
dblog_watchdog($log); |
|
689 |
|
|
690 |
$wid = db_query('SELECT MAX(wid) FROM {watchdog}')->fetchField(); |
|
691 |
$this->drupalGet('admin/reports/event/' . $wid); |
|
692 |
$this->assertResponse(200); |
|
693 |
$this->assertNoRaw("<script>alert('foo');</script>"); |
|
694 |
$this->assertRaw("alert('foo'); <strong>Lorem ipsum</strong>"); |
|
695 |
} |
|
639 | 696 |
} |
Formats disponibles : Unified diff
Update to Drupal 7.52