public function FieldTest::testQuery in Views (for Drupal 7) 8.3
Tests all things related to the query.
File
- lib/
Drupal/ views/ Tests/ Handler/ FieldTest.php, line 61 - Definition of Drupal\views\Tests\Handler\FieldTest.
Class
- FieldTest
- Tests the generic field handler.
Namespace
Drupal\views\Tests\HandlerCode
public function testQuery() {
// Tests adding additional fields to the query.
$view = $this
->getBasicView();
$view
->initHandlers();
$id_field = $view->field['id'];
$id_field->additional_fields['job'] = 'job';
// Choose also a field alias key which doesn't match to the table field.
$id_field->additional_fields['created_test'] = array(
'table' => 'views_test_data',
'field' => 'created',
);
$view
->build();
// Make sure the field aliases have the expected value.
$this
->assertEqual($id_field->aliases['job'], 'views_test_data_job');
$this
->assertEqual($id_field->aliases['created_test'], 'views_test_data_created');
$this
->executeView($view);
// Tests the get_value method with and without a field aliases.
foreach ($this
->dataSet() as $key => $row) {
$id = $key + 1;
$result = $view->result[$key];
$this
->assertEqual($id_field
->get_value($result), $id);
$this
->assertEqual($id_field
->get_value($result, 'job'), $row['job']);
$this
->assertEqual($id_field
->get_value($result, 'created_test'), $row['created']);
}
}