Commit 3e6a3f09 authored by catch's avatar catch

Issue #2898437 by andypost, dawehner, Lendude: Convert HistoryTimestampTest to kernel test

parent 13b5c9f0
<?php
namespace Drupal\history\Tests\Views;
namespace Drupal\Tests\history\Kernel\Views;
use Drupal\node\Entity\Node;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\user\Entity\User;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestBase;
/**
* Tests the history timestamp handlers.
*
* @group history
* @see \Drupal\history\Plugin\views\field\HistoryTimestamp.
* @see \Drupal\history\Plugin\views\filter\HistoryTimestamp.
* @see \Drupal\history\Plugin\views\field\HistoryUserTimestamp
* @see \Drupal\history\Plugin\views\filter\HistoryUserTimestamp
*/
class HistoryTimestampTest extends ViewTestBase {
class HistoryTimestampTest extends ViewsKernelTestBase {
/**
* Modules to enable.
......@@ -28,16 +30,41 @@ class HistoryTimestampTest extends ViewTestBase {
*/
public static $testViews = ['test_history'];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$this->installEntitySchema('node');
$this->installEntitySchema('user');
$this->installSchema('history', ['history']);
// Use classy theme because its marker is wrapped in a span so it can be
// easily targeted with xpath.
\Drupal::service('theme_handler')->install(['classy']);
\Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('classy'));
}
/**
* Tests the handlers.
*/
public function testHandlers() {
$nodes = [];
$nodes[] = $this->drupalCreateNode();
$nodes[] = $this->drupalCreateNode();
$account = $this->drupalCreateUser();
$this->drupalLogin($account);
$node = Node::create([
'title' => 'n1',
'type' => 'default',
]);
$node->save();
$nodes[] = $node;
$node = Node::create([
'title' => 'n2',
'type' => 'default',
]);
$node->save();
$nodes[] = $node;
$account = User::create(['name' => 'admin']);
$account->save();
\Drupal::currentUser()->setAccount($account);
db_insert('history')
......@@ -83,7 +110,6 @@ public function testHandlers() {
$view = Views::getView('test_history');
$view->setDisplay('page_2');
$this->executeView($view);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment