public function BasicTest::testSimpleFiltering in Views (for Drupal 7) 8.3
Tests filtering of the result set.
File
- lib/
Drupal/ views/ Tests/ BasicTest.php, line 49 - Definition of Drupal\views\Tests\BasicTest.
Class
- BasicTest
- Basic test class for Views query builder tests.
Namespace
Drupal\views\TestsCode
public function testSimpleFiltering() {
$view = $this
->getView();
// Add a filter.
$view->displayHandlers['default']
->overrideOption('filters', array(
'age' => array(
'operator' => '<',
'value' => array(
'value' => '28',
'min' => '',
'max' => '',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
),
));
// Execute the view.
$this
->executeView($view);
// Build the expected result.
$dataset = array(
array(
'id' => 1,
'name' => 'John',
'age' => 25,
),
array(
'id' => 2,
'name' => 'George',
'age' => 27,
),
array(
'id' => 4,
'name' => 'Paul',
'age' => 26,
),
);
// Verify the result.
$this
->assertEqual(3, count($view->result), t('The number of returned rows match.'));
$this
->assertIdenticalResultSet($view, $dataset, array(
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
));
}