function SortRandomTest::getBasicRandomView

Same name and namespace 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 <a href="/api/drupal/core%21modules%21views%21src%21Plugin%21views%21sort%21Random.php/class/Random/8.9.x" title="Handle a random sort." class="local">Drupal\views\Plugin\views\sort\Random</a> 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.