function SortRandomTest::getBasicRandomView

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php \Drupal\Tests\views\Kernel\Handler\SortRandomTest::getBasicRandomView()
  2. 10 core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php \Drupal\Tests\views\Kernel\Handler\SortRandomTest::getBasicRandomView()
  3. 11.x 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.