public function FilterInOperatorTest::testFilterInOperatorSimple in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/views/src/Tests/Handler/FilterInOperatorTest.php \Drupal\views\Tests\Handler\FilterInOperatorTest::testFilterInOperatorSimple()
File
- core/
modules/ views/ src/ Tests/ Handler/ FilterInOperatorTest.php, line 51 - Contains \Drupal\views\Tests\Handler\FilterInOperatorTest.
Class
- FilterInOperatorTest
- Tests the core Drupal\views\Plugin\views\filter\InOperator handler.
Namespace
Drupal\views\Tests\HandlerCode
public function testFilterInOperatorSimple() {
$view = Views::getView('test_view');
$view
->setDisplay();
// Add a in_operator ordering.
$view->displayHandlers
->get('default')
->overrideOption('filters', array(
'age' => array(
'id' => 'age',
'field' => 'age',
'table' => 'views_test_data',
'value' => array(
26,
30,
),
'operator' => 'in',
),
));
$this
->executeView($view);
$expected_result = array(
array(
'name' => 'Paul',
'age' => 26,
),
array(
'name' => 'Meredith',
'age' => 30,
),
);
$this
->assertEqual(2, count($view->result));
$this
->assertIdenticalResultset($view, $expected_result, $this->columnMap);
$view
->destroy();
$view
->setDisplay();
// Add a in_operator ordering.
$view->displayHandlers
->get('default')
->overrideOption('filters', array(
'age' => array(
'id' => 'age',
'field' => 'age',
'table' => 'views_test_data',
'value' => array(
26,
30,
),
'operator' => 'not in',
),
));
$this
->executeView($view);
$expected_result = array(
array(
'name' => 'John',
'age' => 25,
),
array(
'name' => 'George',
'age' => 27,
),
array(
'name' => 'Ringo',
'age' => 28,
),
);
$this
->assertEqual(3, count($view->result));
$this
->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}