You are here

public function HandlerAliasTest::testPluginAliases in Views (for Drupal 7) 8.3

File

lib/Drupal/views/Tests/Handler/HandlerAliasTest.php, line 47
Definition of Drupal\views\Tests\Handler\HandlerAliasTest.

Class

HandlerAliasTest
Tests abstract handlers of views.

Namespace

Drupal\views\Tests\Handler

Code

public function testPluginAliases() {
  $view = views_get_view('test_filter');
  $view
    ->initDisplay();

  // Change the filtering.
  $view->displayHandlers['default']
    ->overrideOption('filters', array(
    'test_filter' => array(
      'id' => 'test_filter',
      'table' => 'views_test_data_alias',
      'field' => 'name_alias',
      'operator' => '=',
      'value' => 'John',
      'group' => 0,
    ),
  ));
  $this
    ->executeView($view);
  $filter = $view->filter['test_filter'];

  // Check the definition values are present.
  $this
    ->assertIdentical($filter->definition['real table'], 'views_test_data');
  $this
    ->assertIdentical($filter->definition['real field'], 'name');
  $this
    ->assertIdentical($filter->table, 'views_test_data');
  $this
    ->assertIdentical($filter->realField, 'name');

  // Test an existing user uid field.
  $view = views_get_view('test_alias');
  $view
    ->initDisplay();
  $this
    ->executeView($view);
  $filter = $view->filter['uid_raw'];
  $this
    ->assertIdentical($filter->definition['real field'], 'uid');
  $this
    ->assertIdentical($filter->field, 'uid_raw');
  $this
    ->assertIdentical($filter->table, 'users');
  $this
    ->assertIdentical($filter->realField, 'uid');
}