1 views_handler_sort_random.test public ViewsHandlerSortRandomTest::testRandomOrdering()

Tests random ordering of the result set.

See also

DatabaseSelectTestCase::testRandomOrder()

File

core/modules/views/tests/handlers/views_handler_sort_random.test, line 52
Definition of ViewsHandlerSortRandomTest.

Class

ViewsHandlerSortRandomTest
Tests for core views_handler_sort_random handler.

Code

public function testRandomOrdering() {
  // Execute a basic view first.
  $view = $this->getBasicView();
  $this->executeView($view);

  // Verify the result.
  $this->assertEqual(count($this->dataSet()), count($view->result), t('The number of returned rows match.'));
  $this->assertIdenticalResultset($view, $this->dataSet(), array(
    'views_test_name' => 'name',
    'views_test_age' => 'age',
  ));

  // Execute a random view, we expect the result set to be different.
  $view_random = $this->getBasicRandomView();
  $this->executeView($view_random);
  $this->assertEqual(count($this->dataSet()), count($view_random->result), t('The number of returned rows match.'));
  $this->assertNotIdenticalResultset($view_random, $view->result, array(
    'views_test_name' => 'views_test_name',
    'views_test_age' => 'views_test_name',
  ));

  // Execute a second random view, we expect the result set to be different again.
  $view_random_2 = $this->getBasicRandomView();
  $this->executeView($view_random_2);
  $this->assertEqual(count($this->dataSet()), count($view_random_2->result), t('The number of returned rows match.'));
  $this->assertNotIdenticalResultset($view_random, $view->result, array(
    'views_test_name' => 'views_test_name',
    'views_test_age' => 'views_test_name',
  ));
}