diff --git a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php b/core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php similarity index 62% rename from core/modules/history/src/Tests/Views/HistoryTimestampTest.php rename to core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php index 476653839285115b2b42d7b965af3dbef47b0f74..b9d345e1db8d071de4e17e57bc8a5d10adba0371 100644 --- a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php +++ b/core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php @@ -1,18 +1,20 @@ <?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); - } }