You are here

protected function SortRandomTest::getBasicRandomView in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php \Drupal\Tests\views\Kernel\Handler\SortRandomTest::getBasicRandomView()

Return a basic view with random ordering.

2 calls to SortRandomTest::getBasicRandomView()
SortRandomTest::testRandomOrdering in core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php
Tests random ordering of the result set.
SortRandomTest::testRandomOrderingWithRenderCaching in core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php
Tests random ordering with tags based caching.

File

core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php, line 51

Class

SortRandomTest
Tests for core Drupal\views\Plugin\views\sort\Random handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

protected function getBasicRandomView() {
  $view = Views::getView('test_view');
  $view
    ->setDisplay();

  // Add a random ordering.
  $view->displayHandlers
    ->get('default')
    ->overrideOption('sorts', [
    'random' => [
      'id' => 'random',
      'field' => 'random',
      'table' => 'views',
    ],
  ]);
  return $view;
}