You are here

public function FieldUrlTest::testFieldUrl in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Handler/FieldUrlTest.php \Drupal\views\Tests\Handler\FieldUrlTest::testFieldUrl()

File

core/modules/views/src/Tests/Handler/FieldUrlTest.php, line 41
Contains \Drupal\views\Tests\Handler\FieldUrlTest.

Class

FieldUrlTest
Tests the core Drupal\views\Plugin\views\field\Url handler.

Namespace

Drupal\views\Tests\Handler

Code

public function testFieldUrl() {
  $view = Views::getView('test_view');
  $view
    ->setDisplay();
  $view->displayHandlers
    ->get('default')
    ->overrideOption('fields', array(
    'name' => array(
      'id' => 'name',
      'table' => 'views_test_data',
      'field' => 'name',
      'relationship' => 'none',
      'display_as_link' => FALSE,
    ),
  ));
  $this
    ->executeView($view);
  $this
    ->assertEqual('John', $view->field['name']
    ->advancedRender($view->result[0]));

  // Make the url a link.
  $view
    ->destroy();
  $view
    ->setDisplay();
  $view->displayHandlers
    ->get('default')
    ->overrideOption('fields', array(
    'name' => array(
      'id' => 'name',
      'table' => 'views_test_data',
      'field' => 'name',
      'relationship' => 'none',
    ),
  ));
  $this
    ->executeView($view);
  $this
    ->assertEqual(\Drupal::l('John', Url::fromUri('base:John')), $view->field['name']
    ->advancedRender($view->result[0]));
}