function SortRandomTest::dataSet

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php \Drupal\Tests\views\Kernel\Handler\SortRandomTest::dataSet()
  2. 8.9.x core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php \Drupal\Tests\views\Kernel\Handler\SortRandomTest::dataSet()
  3. 11.x core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php \Drupal\Tests\views\Kernel\Handler\SortRandomTest::dataSet()

Add more items to the test set, to make the order tests more robust.

In total we have then 60 entries, which makes a probability of a collision of 1/60!, which is around 1/1E80, which is higher than the estimated amount of protons / electrons in the observable universe, also called the eddington number.

Overrides ViewsKernelTestBase::dataSet

See also

http://wikipedia.org/wiki/Eddington_number

1 call to SortRandomTest::dataSet()
SortRandomTest::testRandomOrdering in core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php
Tests random ordering of the result set.

File

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

Class

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

Namespace

Drupal\Tests\views\Kernel\Handler

Code

protected function dataSet() {
    $data = parent::dataSet();
    for ($i = 0; $i < 55; $i++) {
        $data[] = [
            'name' => 'name_' . $i,
            'age' => $i,
            'job' => 'job_' . $i,
            'created' => rand(0, time()),
            'status' => 1,
        ];
    }
    return $data;
}

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