updated core to 8.6.1 via composer
This commit is contained in:
@@ -5,5 +5,5 @@ package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- dblog
|
||||
- views
|
||||
- drupal:dblog
|
||||
- drupal:views
|
||||
|
||||
@@ -18,6 +18,7 @@ use Drupal\Tests\Traits\Core\CronRunTrait;
|
||||
*/
|
||||
class DbLogTest extends BrowserTestBase {
|
||||
use CronRunTrait;
|
||||
use FakeLogEntries;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
@@ -182,55 +183,6 @@ class DbLogTest extends BrowserTestBase {
|
||||
return $current_id - $last_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a number of random database log events.
|
||||
*
|
||||
* @param int $count
|
||||
* Number of watchdog entries to generate.
|
||||
* @param array $options
|
||||
* These options are used to override the defaults for the test.
|
||||
* An associative array containing any of the following keys:
|
||||
* - 'channel': String identifying the log channel to be output to.
|
||||
* If the channel is not set, the default of 'custom' will be used.
|
||||
* - 'message': String containing a message to be output to the log.
|
||||
* A simple default message is used if not provided.
|
||||
* - 'variables': Array of variables that match the message string.
|
||||
* - 'severity': Log severity level as defined in logging_severity_levels.
|
||||
* - 'link': String linking to view the result of the event.
|
||||
* - 'user': String identifying the username.
|
||||
* - 'uid': Int identifying the user id for the user.
|
||||
* - 'request_uri': String identifying the location of the request.
|
||||
* - 'referer': String identifying the referring url.
|
||||
* - 'ip': String The ip address of the client machine triggering the log
|
||||
* entry.
|
||||
* - 'timestamp': Int unix timestamp.
|
||||
*/
|
||||
private function generateLogEntries($count, $options = []) {
|
||||
global $base_root;
|
||||
|
||||
// Prepare the fields to be logged
|
||||
$log = $options + [
|
||||
'channel' => 'custom',
|
||||
'message' => 'Dblog test log message',
|
||||
'variables' => [],
|
||||
'severity' => RfcLogLevel::NOTICE,
|
||||
'link' => NULL,
|
||||
'user' => $this->adminUser,
|
||||
'uid' => $this->adminUser->id(),
|
||||
'request_uri' => $base_root . \Drupal::request()->getRequestUri(),
|
||||
'referer' => \Drupal::request()->server->get('HTTP_REFERER'),
|
||||
'ip' => '127.0.0.1',
|
||||
'timestamp' => REQUEST_TIME,
|
||||
];
|
||||
|
||||
$logger = $this->container->get('logger.dblog');
|
||||
$message = $log['message'] . ' Entry #';
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$log['message'] = $message . $i;
|
||||
$logger->log($log['severity'], $log['message'], $log);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the entry logs by clicking on 'Clear log messages' button.
|
||||
*/
|
||||
@@ -432,7 +384,7 @@ class DbLogTest extends BrowserTestBase {
|
||||
$value = $links->getAttribute('href');
|
||||
|
||||
// Extract link to details page.
|
||||
$link = Unicode::substr($value, strpos($value, 'admin/reports/dblog/event/'));
|
||||
$link = mb_substr($value, strpos($value, 'admin/reports/dblog/event/'));
|
||||
$this->drupalGet($link);
|
||||
// Check for full message text on the details page.
|
||||
$this->assertRaw($message, 'DBLog event details was found: [delete user]');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\Tests\dblog\Functional;
|
||||
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Generate events and verify dblog entries; verify user access to log reports
|
||||
@@ -44,27 +44,16 @@ class DbLogViewsTest extends DbLogTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Tests the empty text for the watchdog view is not using an input format.
|
||||
*/
|
||||
public function testDBLogAddAndClear() {
|
||||
// Is necesary to create the basic_html format because if absent after
|
||||
// delete the logs, a new log entry is created indicating that basic_html
|
||||
// format do not exists.
|
||||
$basic_html_format = FilterFormat::create([
|
||||
'format' => 'basic_html',
|
||||
'name' => 'Basic HTML',
|
||||
'filters' => [
|
||||
'filter_html' => [
|
||||
'status' => 1,
|
||||
'settings' => [
|
||||
'allowed_html' => '<p> <br> <strong> <a> <em>',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
$basic_html_format->save();
|
||||
public function testEmptyText() {
|
||||
$view = Views::getView('watchdog');
|
||||
$data = $view->storage->toArray();
|
||||
$area = $data['display']['default']['display_options']['empty']['area'];
|
||||
|
||||
parent::testDBLogAddAndClear();
|
||||
$this->assertEqual('text_custom', $area['plugin_id']);
|
||||
$this->assertEqual('area_text_custom', $area['field']);
|
||||
$this->assertEqual('No log messages available.', $area['content']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\dblog\Functional;
|
||||
|
||||
use Drupal\Core\Logger\RfcLogLevel;
|
||||
use Drupal\Core\Session\AnonymousUserSession;
|
||||
|
||||
/**
|
||||
* Provides methods to generate log entries.
|
||||
*
|
||||
* This trait is meant to be used only by test classes.
|
||||
*/
|
||||
trait FakeLogEntries {
|
||||
|
||||
/**
|
||||
* Generates a number of random database log events.
|
||||
*
|
||||
* @param int $count
|
||||
* Number of watchdog entries to generate.
|
||||
* @param array $options
|
||||
* These options are used to override the defaults for the test.
|
||||
* An associative array containing any of the following keys:
|
||||
* - 'channel': String identifying the log channel to be output to.
|
||||
* If the channel is not set, the default of 'custom' will be used.
|
||||
* - 'message': String containing a message to be output to the log.
|
||||
* A simple default message is used if not provided.
|
||||
* - 'variables': Array of variables that match the message string.
|
||||
* - 'severity': Log severity level as defined in logging_severity_levels.
|
||||
* - 'link': String linking to view the result of the event.
|
||||
* - 'user': String identifying the username.
|
||||
* - 'uid': Int identifying the user id for the user.
|
||||
* - 'request_uri': String identifying the location of the request.
|
||||
* - 'referer': String identifying the referring url.
|
||||
* - 'ip': String The ip address of the client machine triggering the log
|
||||
* entry.
|
||||
* - 'timestamp': Int unix timestamp.
|
||||
*/
|
||||
private function generateLogEntries($count, $options = []) {
|
||||
global $base_root;
|
||||
|
||||
$user = !empty($this->adminUser) ? $this->adminUser : new AnonymousUserSession();
|
||||
|
||||
// Prepare the fields to be logged.
|
||||
$log = $options + [
|
||||
'channel' => 'custom',
|
||||
'message' => 'Dblog test log message',
|
||||
'variables' => [],
|
||||
'severity' => RfcLogLevel::NOTICE,
|
||||
'link' => NULL,
|
||||
'user' => $user,
|
||||
'uid' => $user->id(),
|
||||
'request_uri' => $base_root . \Drupal::request()->getRequestUri(),
|
||||
'referer' => \Drupal::request()->server->get('HTTP_REFERER'),
|
||||
'ip' => '127.0.0.1',
|
||||
'timestamp' => REQUEST_TIME,
|
||||
];
|
||||
|
||||
$logger = $this->container->get('logger.dblog');
|
||||
$message = $log['message'] . ' Entry #';
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$log['message'] = $message . $i;
|
||||
$logger->log($log['severity'], $log['message'], $log);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ use Drupal\Core\Serialization\Yaml;
|
||||
* @see dblog_update_8400()
|
||||
*
|
||||
* @group Update
|
||||
* @group legacy
|
||||
*/
|
||||
class DblogFiltersAndFieldsUpgradeTest extends UpdatePathTestBase {
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\dblog\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Test the upgrade path of changing the emtpy text area for watchdog view.
|
||||
*
|
||||
* @see dblog_update_8600()
|
||||
*
|
||||
* @group Update
|
||||
* @group legacy
|
||||
*/
|
||||
class DblogNoLogsAvailableUpgradeTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.4.0.bare.standard.php.gz',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that no logs available text is now using a custom area.
|
||||
*/
|
||||
public function testDblogUpgradePath() {
|
||||
|
||||
$this->runUpdates();
|
||||
|
||||
$view = Views::getView('watchdog');
|
||||
$data = $view->storage->toArray();
|
||||
$area = $data['display']['default']['display_options']['empty']['area'];
|
||||
|
||||
$this->assertEqual('text_custom', $area['plugin_id']);
|
||||
$this->assertEqual('area_text_custom', $area['field']);
|
||||
$this->assertEqual('No log messages available.', $area['content']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
* Ensures that update hook that creates the watchdog view ran sucessfully.
|
||||
*
|
||||
* @group Update
|
||||
* @group legacy
|
||||
*/
|
||||
class DblogRecentLogsUsingViewsUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\Tests\dblog\Kernel\Views;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Logger\RfcLogLevel;
|
||||
use Drupal\Core\Url;
|
||||
@@ -62,7 +62,7 @@ class ViewsIntegrationTest extends ViewsKernelTestBase {
|
||||
if (!isset($entry['variables'])) {
|
||||
continue;
|
||||
}
|
||||
$this->assertEqual($view->style_plugin->getField($index, 'message'), SafeMarkup::format($entry['message'], $entry['variables']));
|
||||
$this->assertEqual($view->style_plugin->getField($index, 'message'), new FormattableMarkup($entry['message'], $entry['variables']));
|
||||
$link_field = $view->style_plugin->getField($index, 'link');
|
||||
// The 3rd entry contains some unsafe markup that needs to get filtered.
|
||||
if ($index == 2) {
|
||||
|
||||
Reference in New Issue
Block a user