You are here

protected function SortRandomTest::dataSet in Drupal 8

Same name and namespace in other branches
  1. 9 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 34

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;
}